New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace RedirectSlashes with smartRedirectSlashes #3385
Conversation
FYI: @tchssk case 1: mux router
case 2: chi router
case 3: chi + RedirectSlashes
What would be the accessibility of this |
If patterns are defined in design as GET("/about")
GET("/posts/")
POST("/posts") the routings would be as follows
In httphtreemux, if a pattern with a trailing slash is added for a method , all other methods for that pattern will also be considered to have a trailing slash. This is not covered by smartRedirectSlashes because it's about routing and needs to be resolved when registering the handlers. |
LGTM, if backward compatibility with treemux is important. |
Great discussion!
Maybe we have an opportunity to remove this implicit behavior as we move to chi. We do need to consider backwards compatibility though. Here are my thoughts:
This way the new behavior is less surprising but users that rely on the implicit redirect can mount the middleware. |
That makes sense. |
I created new two pull requests. |
Related to #3366
RedirectSlashes middleware was not suitable for Goa.
RedirectSlashes redirects a request with a trailing slash to the same path without slash.
It also works for patterns with a trailing slash, so they are no longer accesible.
(@ikawaha told me that. Thank you so much.)
I replaced the middleware with a new one.
It redirects both paths with and withohut a trailing slash according to defined patterns.