mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
957c3fcb59
Fix #17880 Co-authored-by: Lauris BH <lauris@nix.lv>
17 lines
422 B
Go
Vendored
17 lines
422 B
Go
Vendored
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)
|
|
})
|
|
}
|
|
}
|