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

Handle trailing / in routes #369

Open
asymmetric opened this issue Dec 11, 2024 · 4 comments
Open

Handle trailing / in routes #369

asymmetric opened this issue Dec 11, 2024 · 4 comments

Comments

@asymmetric
Copy link
Contributor

Currently, one has to separately handle the presence/absence of trailing slashes, by having a route for "", and one for "/".

I think it would be more intuitive if a trailing slash were automatically added, or removed, via redirects.

For the record, Go's serveMux does the former.

@aantron
Copy link
Owner

aantron commented Dec 11, 2024

IIRC Dream sticks to the RFCs in treating these differently, as, IIRC, "" refers to a file-like resource and "/" to a directory. It may be a little old-fashioned. This could be a good use case for a middleware.

@yawaramin
Copy link
Contributor

Maybe we could introduce a small new addition to the Dream path syntax to handle an optional trailing slash, eg /foo:/ could match against both /foo and /foo/?

@briangwaltney
Copy link

I was working on middleware for a project and noticed "Router path access is being removed from the API."

Dream.path and Dream.with_path both are showing this error.

Is there a way to handle this with the functions still available?

@yawaramin
Copy link
Contributor

I guess with Dream.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants