Update chi/middleware to chi/v5/middleware (#17888)
Fix #17880 Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
4646c7c52d
commit
957c3fcb59
42 changed files with 128 additions and 2572 deletions
20
vendor/github.com/go-chi/chi/v5/middleware/page_route.go
generated
vendored
Normal file
20
vendor/github.com/go-chi/chi/v5/middleware/page_route.go
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PageRoute is a simple middleware which allows you to route a static GET request
|
||||
// at the middleware stack level.
|
||||
func PageRoute(path string, handler http.Handler) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "GET" && strings.EqualFold(r.URL.Path, path) {
|
||||
handler.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue