initial commit

This commit is contained in:
2025-02-22 23:00:56 +08:00
commit da25659f6f
20 changed files with 1676 additions and 0 deletions

18
middleware/slash/slash.go Normal file
View File

@ -0,0 +1,18 @@
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)
})
})
}