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
Hmm this is surely from the router resolution algorithm. using the same names work but it fails when different names are used... Maybe I'll try looking into it. Do you have any leads?
This is because the nodes on the Router only have an internal structure to store the path parameters (pnames), and the same node is used for all the HTTP methods. That's the reason why the path parameters that ends up in the node for that url are the ones of the PUT (vid and gid)
I guess I have and idea of how to fix it, but I need to think a little bit more about it to find out if it is the simplest and more performant solution.
After thinking and reasoning about why currently router has that behavour. I would say - it is correct.
Why would parameter at same place be conceptually different for GET vs PUT methods?
in REST sense having different parameter identifier for same field "/users/:vid/files/:gid" and /users/:uid/files/:fid -> :vid vs :uid it not conceptually correct. In case when one route parameter at same place is uid and in another gid - It would say - both should be the same for all router with same prefix.
This is because by REST idea (route describes path to entity). So in our case both (vid and uid) should refer to same uniquely linkable path i.e. having same user entity id by having same parameter name.
Probably in forcing user to use same parameter names for parameter at same place is more consistent for their API and code readability.
I have a little PR that panics when the same route with different route params is added (regarding HTTP method). If everyone agrees I can submit it. If someone upgrades Echo to that code, I think it will be easy to fix it, but besides of that maybe the PR should be tagged as v5. Any thoughts?
Activity
iambenkay commentedon Dec 18, 2020
Hmm this is surely from the router resolution algorithm. using the same names work but it fails when different names are used... Maybe I'll try looking into it. Do you have any leads?
pafuent commentedon Dec 19, 2020
This is because the nodes on the Router only have an internal structure to store the path parameters (pnames), and the same node is used for all the HTTP methods. That's the reason why the path parameters that ends up in the node for that url are the ones of the PUT (vid and gid)
I guess I have and idea of how to fix it, but I need to think a little bit more about it to find out if it is the simplest and more performant solution.
aldas commentedon Jan 25, 2021
After thinking and reasoning about why currently router has that behavour. I would say - it is correct.
Why would parameter at same place be conceptually different for GET vs PUT methods?
in REST sense having different parameter identifier for same field
"/users/:vid/files/:gid"and/users/:uid/files/:fid->:vidvs:uidit not conceptually correct. In case when one route parameter at same place isuidand in anothergid- It would say - both should be the same for all router with same prefix.This is because by REST idea (route describes path to entity). So in our case both (
vidanduid) should refer to same uniquely linkable path i.e. having sameuser entity idby having same parameter name.Probably in forcing user to use same parameter names for parameter at same place is more consistent for their API and code readability.
pafuent commentedon Jan 26, 2021
@aldas I agree with you.
I have a little PR that panics when the same route with different route params is added (regarding HTTP method). If everyone agrees I can submit it. If someone upgrades Echo to that code, I think it will be easy to fix it, but besides of that maybe the PR should be tagged as v5. Any thoughts?
Panic when a route is added with different path params