mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-15 17:49:20 +08:00
c296f4fed6
* When route cannot be found on chi, go to macaron * Stick chi version to 1.5.0 * Follow router log setting
24 lines
684 B
Go
Vendored
24 lines
684 B
Go
Vendored
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
|
|
}
|