1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-28 03:28:13 +00:00

Update chi/middleware to chi/v5/middleware (#17888)

Fix #17880


Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
zeripath
2021-12-02 20:58:08 +00:00
committed by GitHub
parent 4646c7c52d
commit 957c3fcb59
42 changed files with 128 additions and 2572 deletions

View File

@@ -0,0 +1,16 @@
package middleware
import (
"net/http"
"strings"
)
// PathRewrite is a simple middleware which allows you to rewrite the request URL path.
func PathRewrite(old, new string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.URL.Path = strings.Replace(r.URL.Path, old, new, 1)
next.ServeHTTP(w, r)
})
}
}