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
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.
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:
The text was updated successfully, but these errors were encountered: