initial commit
This commit is contained in:
18
middleware/slash/slash.go
Normal file
18
middleware/slash/slash.go
Normal 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)
|
||||
})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user