1package middleware
2
3import "net/http"
4
5// New will create a new middleware handler from a http.Handler.
6func New(h http.Handler) func(next http.Handler) http.Handler {
7	return func(next http.Handler) http.Handler {
8		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
9			h.ServeHTTP(w, r)
10		})
11	}
12}
13
14// contextKey is a value for use with context.WithValue. It's used as
15// a pointer so it fits in an interface{} without allocation. This technique
16// for defining context keys was copied from Go 1.7's new use of context in net/http.
17type contextKey struct {
18	name string
19}
20
21func (k *contextKey) String() string {
22	return "chi/middleware context value " + k.name
23}
24