Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package middleware

import (
	
	
	
)
Timeout returns a new Middleware that times out each request after the given duration.
func ( time.Duration) Middleware {
	return func( http.Handler) http.Handler {
		return http.HandlerFunc(func( http.ResponseWriter,  *http.Request) {
			,  := context.WithTimeout(.Context(), )
			defer ()
			.ServeHTTP(, .WithContext())
		})
	}