diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-11-13 20:51:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 14:51:07 +0200 |
commit | c296f4fed66288431fa7ec3a64f990beccd29eb1 (patch) | |
tree | 6b2f1971303967671bd5da1d1149407e410d62bd /vendor/github.com/go-chi/chi/middleware/middleware.go | |
parent | 0ae35c66f2efe608e3176f796866c18461f0780f (diff) | |
download | gitea-c296f4fed66288431fa7ec3a64f990beccd29eb1.tar.gz gitea-c296f4fed66288431fa7ec3a64f990beccd29eb1.zip |
Introduce go chi web framework as frontend of macaron, so that we can move routes from macaron to chi step by step (#7420)
* When route cannot be found on chi, go to macaron
* Stick chi version to 1.5.0
* Follow router log setting
Diffstat (limited to 'vendor/github.com/go-chi/chi/middleware/middleware.go')
-rw-r--r-- | vendor/github.com/go-chi/chi/middleware/middleware.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/go-chi/chi/middleware/middleware.go b/vendor/github.com/go-chi/chi/middleware/middleware.go new file mode 100644 index 0000000000..cc371e00a8 --- /dev/null +++ b/vendor/github.com/go-chi/chi/middleware/middleware.go @@ -0,0 +1,23 @@ +package middleware + +import "net/http" + +// New will create a new middleware handler from a http.Handler. +func New(h http.Handler) func(next http.Handler) http.Handler { + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + h.ServeHTTP(w, r) + }) + } +} + +// contextKey is a value for use with context.WithValue. It's used as +// a pointer so it fits in an interface{} without allocation. This technique +// for defining context keys was copied from Go 1.7's new use of context in net/http. +type contextKey struct { + name string +} + +func (k *contextKey) String() string { + return "chi/middleware context value " + k.name +} |