You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have come across an issue where redirect slash middleware will drop the url query params.
I have managed to temporarily fix it with:
// RedirectSlashes is a middleware that will match request paths with a trailing
// slash and redirect to the same path, less the trailing slash.
func RedirectSlashes(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
var path string
rctx := chi.RouteContext(r.Context())
if rctx.RoutePath != "" {
path = rctx.RoutePath
} else {
path = r.URL.Path
}
if len(path) > 1 && path[len(path)-1] == '/' {
path = fmt.Sprintf("%s?%s", path[:len(path)-1], r.URL.RawQuery)
http.Redirect(w, r, path, 301)
return
}
next.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}
But it feels somewhat incomplete
The text was updated successfully, but these errors were encountered:
I have come across an issue where redirect slash middleware will drop the url query params.
I have managed to temporarily fix it with:
But it feels somewhat incomplete
The text was updated successfully, but these errors were encountered: