mirror of
https://github.com/adnanh/webhook.git
synced 2026-07-27 01:29:16 +08:00
0fa8bbf710
* Update go-chi dependency to v5 * Update gofrs/uuid dependency to v5 * Update gorilla/mux dependency to v1.8.1 * Update go-humanize dependency to v1.0.1 * Update mxj dependency to v2.7.0 * Update fsnotify dependency to v1.7.0 * Update Go versions in GH build workflow * Update gopkg.in/yaml.v2 indirect dependency to v2.4.0 * Bump GH actions
17 lines
422 B
Go
17 lines
422 B
Go
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)
|
|
})
|
|
}
|
|
}
|