Skip to content
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

customization of NormalizePath behavior #1612

Closed
robjtede opened this issue Jul 19, 2020 · 2 comments · Fixed by #1639
Closed

customization of NormalizePath behavior #1612

robjtede opened this issue Jul 19, 2020 · 2 comments · Fixed by #1639
Labels
C-improvement Category: an improvement to existing functionality

Comments

@robjtede
Copy link
Member

excerpt from #959

I think had hoped that NormalizePath might let you create a route like /hello and accept either /hello or /hello/ I suppose this can also be achieved via route matching (e.g. #[get(r#"/hello{tail:/?}"#)]) (as an aside: I also wonder if users would prefer to accept both distinct routes or have one version 301 redirect to the other?).

When I tried to check v3 beta, seems like my usage of NormalizePath did not work for me? Not sure if I have something mixed up here, but wasn't able to access either /hello or /hello/.

So, middleware should take option TrailingSlash::{Always, Trim} and possibly an option to 301 redirect to the normalized path.

@ljoonal
Copy link
Contributor

ljoonal commented Aug 17, 2020

I'd be interested to get something like this added. I made a small branch to test it on even. But I by no means thought a ton about the implementation, so it'd probably be good for someone to see if I missed something obvious 😅

@robjtede
Copy link
Member Author

@ljoonal looks like a good start. feel free to open a draft PR to get the implementation discussion going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-improvement Category: an improvement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants