-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Stacked versioning broken when not using :path
version method
#1799
Comments
@nickrivadeneira could you please PR these tests? Thanks |
@dblock After some more investigation, it looks like versioning occurs after the router attempts to match the path to routes. Ideally versioning would normalize paths before the router attempts to match path to route. One suggestion would be to have the API instance build the middleware stack, turn the router into middleware (which it already technically is), and put the versioning middleware before the router. This way, path matching can occur agnostic of versioning method since the path would have been normalized by the versioning middleware. This would be a fairly large change from how things work now, so I'm hoping for some feedback before I attempt anything. |
I think different versioning schemes may want to behave differently, path versioning may need to be inserted at a different time. I do think you should attempt what you're proposing! We have lots of tests and eyes here, so we'll know what breaks :) |
Upgrading from
0.18.0
to0.19.0
breaks our app when we use:accept_version_header
, version arrays for fallbacks, and a catch-all. I wrote this series of tests (at bottom) to verify, and all non-path catch-all tests fail.After extensive investigation, it looks like
:path
versioning works because it matches using the@optimized_router
immediately based on the/:version/:path
pattern. When using other versioning methods and stacked versioning, version is not correctly found with the optimized router since the path pattern does not include the version. Before0.19.0
, this worked fine because the response would fall back toRouter#rotation
, which properly matches the correct version. After0.19.0
, the catch-all match has been prioritized overRouter#rotation
and prevents a correct version match.Two approaches that could address this:
*
match to after the#rotation
match, that could make things work.The best option would be #2, but I wanted to get some feedback before going too deep with either option. In the meantime on our app, we'll likely configure our app to use
:path
versioning, and then add some middleware that transforms any header versioned requests into path versioned requests.The text was updated successfully, but these errors were encountered: