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

Allow rack/mount cascading to be skipped on header #339

Merged
merged 1 commit into from
Feb 18, 2013
Merged

Allow rack/mount cascading to be skipped on header #339

merged 1 commit into from
Feb 18, 2013

Conversation

dieb
Copy link
Contributor

@dieb dieb commented Feb 18, 2013

When using header versioning with the :strict policy, Grape currently returns the appropriate error (406 Not Acceptable) but it also returns a X-Cascade header indicating to rack it should keep looking for other routes.

While this behavior is expected for various applications, some may need to skip the cascading and explicitly return the error to the requester.

For that, a :cascade option was added to the version method. The default value is true (keeping backwards compat), meaning that 406 errors shall be raised along with X-Cascade headers, just like before. Though, if set to false, it 406 errors shall be raised with no X-Cascade headers, therefore telling the router it should not lookup other routes.

@dblock
Copy link
Member

dblock commented Feb 18, 2013

Looks good. Can you please:

  • Update README, documenting the new cascade option.
  • Update CHANGELOG.
  • Minor, since (cascade? ? {'X-Cascade' => 'pass'} : {}) is repeated 3 times, maybe there's a cleaner way by creating a error_headers private method or something like that?

When using header versioning with the :strict policy, Grape currently
returns the appropriate error (406 Not Acceptable) but it also returns a
X-Cascade header indicating to rack it should keep looking for
other routes.

While this behavior is expected for various applications, some may need
to skip the cascading and explicitly return the error to the requester.

For that, a :cascade option was added to the version method. The default
value is true (keeping backwards compat), meaning that 406 errors shall
be raised along with X-Cascade headers, just like before. Though, if set
to false, it 406 errors shall be raised with no X-Cascade headers,
therefore telling the router it should not lookup other routes.
@dieb
Copy link
Contributor Author

dieb commented Feb 18, 2013

Fixed the suggested issues. Great suggestions btw.

Let me know if there's anything I can help with.

@dblock dblock merged commit c81af68 into ruby-grape:master Feb 18, 2013
@dblock
Copy link
Member

dblock commented Feb 18, 2013

Merged with minor README and code updates. Thank you very much.

@dieb dieb deleted the feature-optional-route-cascading branch February 18, 2013 19:50
@dieb
Copy link
Contributor Author

dieb commented Feb 19, 2013

Thanks @dblock!

PS: Sorry for the coding style issues.

BR

@dblock
Copy link
Member

dblock commented Feb 19, 2013

Coding style wasn't an issue. I am just obsessive-compulsive ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants