-
Notifications
You must be signed in to change notification settings - Fork 257
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
Implement #238, handle trailing slashes in frontend match-by-path #239
base: master
Are you sure you want to change the base?
Conversation
(if-let [match (r/match-by-path router (.getPath uri))] | ||
(let [uri (.parse Uri path) | ||
path (.getPath uri)] | ||
(if-let [match (or (r/match-by-path router path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make the lookup much slower as there is an extra hash-lookup for each routing call. Would be better to move the check into router creation time and return a reified r.c/Router
with different code for the different cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still think this would be cleaner to be implemented as a reified Proxy, but that could be done later too.
|
||
| key | description | | ||
| -------------|-------------| | ||
| :trailing-slash-handling | TODO | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be just :trailing-slash
(or :trailing-slash-method
(the ring-version has :method
)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0923527
to
54a26ad
Compare
Now implemented as custom Router, which wraps the parent router. TODO:
|
I remembered some reason why it might not be necessary or even good idea to move this to core: Frontend and backend have quite a different solutions on what to do in these cases: this frontend solution just returns the match as if the original route was matched. In backend ring handler will return redirect response. |
I can't talk about the implementation details (moving to core or not), but my 2c on (my) desired behaviour in the frontend:
Thank you for your work on this! |
Not sure if useful for anyone, but here's a small snippet that seems to do the trick:
|
(if (not= method :remove) | ||
(r/match-by-path parent (str path "/")))))) | ||
(match-by-name [_ name] | ||
(r/match-by-name parent name))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also need implementation
(match-by-name [_ name path-params]
(r/match-by-name parent name path-params))
Does adding option to router make sense? Are there other ways to control this logic?