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) }) }) }