2025-02-22 23:06:16 +08:00

19 lines
432 B
Go

package slash
import (
"net/http"
"git.jeffthecoder.xyz/public/lazyhandler/middleware"
)
func StripSlash() middleware.Middleware {
return middleware.WrapFunc(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path[len(r.URL.Path)-1] == '/' && len(r.URL.Path) > 1 {
r.URL.Path = r.URL.Path[:len(r.URL.Path)-1]
}
next.ServeHTTP(w, r)
})
})
}