build source
This commit is contained in:
commit
ee1fec43ed
4171 changed files with 1351288 additions and 0 deletions
16
vendor/github.com/go-chi/chi/v5/middleware/path_rewrite.go
generated
vendored
Normal file
16
vendor/github.com/go-chi/chi/v5/middleware/path_rewrite.go
generated
vendored
Normal 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue