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

Middleware called for incorrect versions #1466

Open
gmassanek opened this issue Jul 27, 2016 · 0 comments
Open

Middleware called for incorrect versions #1466

gmassanek opened this issue Jul 27, 2016 · 0 comments
Labels

Comments

@gmassanek
Copy link

When setting up api versions that fall back from newer to older, middlewares will be called twice. I believe its related to how lib/grape/router.rb tries the first matching endpoint it finds, then falls back to other matching endpoints if the first response is empty. Because the version is checked in middleware, it executes all the middleware above it before breaking because its the incorrect version.

One workaround would be to add any custom middleware after the Version middleware, but the insert_after methods are not available in 0.16.0.

I took a stab at adding a version check in lib/grape/router.rb, but the version code is spread across multiple middlewares so it would need to be consolidated first.

It might also be possible to update the registration of the Version middleware to put it at the top of the stack.

I'm happy to help code up a solution if needed, but I could use some guidance from those more familiar with the inner Grape workings.

Reference:

@dblock dblock added the bug? label Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants