-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add version support in response header #25
Add version support in response header #25
Conversation
…l when the requested version is not supported. The is_newer_version boolean should be set to true when a requested version is newer than any of the currently supported versions and the is_older_version should be set to true when a requested version is deprecated.
…pending on the requested and supported versions. Moved the raising of the ActionController::RoutingErrors to the controller_additions.rb.
…leans to the controller.
…he exposed variables and the header value on the response are still set.
…ed version is supported or not. The header will only be set if the user provides a value for the response_header_key configuration variable.
@richardnuno thanks for the pull request. Can you expand on your use case for this feature? Thanks! |
Sure thing. The use case is the consumer of the api being able to determine whether the requested version is supported or not when making an ajax request without relying on the http status code and matching of the error message strings. The is_older_version and is_newer_version variables were added as a way to customize the error handling on the consumer depending on whether the version is deprecated or larger than the most recent supported version. Please let me know if you have any suggestions/thoughts on the feature, happy to make the necessary changes. |
@richardnuno Could you add a code example to the Readme that outlines this use case? It's probably easier to evaluate it that way. |
…tion variables. Also added an example of how to read the response header with a JavaScript consumer.
@aantix I've updated the README to contain information about the new variables and an example of how a JavaScript consumer would use the header value to determine if an unsupported version was requested. Let me know if you have any concerns or suggestions on how to improve it. |
@richardnuno Thanks for the clarification of your problem. It seems that this is very close to another recent issue #24. I think that returning a header field during unsupported version request is a little too specific for Version Cake to handle specifically. That being said, I have taken your PR as a base and attempted to make a more general solution to allow applications to handle unsupported requests in their own way. I would appreciate if you review my PR #26-your feedback would be greatly appreciated. |
Added the ability to specify a response header key in the configuration. When defined, a header field with that key and a value of "true" or "false" (depending on whether the requested version is supported or not) will be set on the response.
Expose is_older_version and is_newer_version booleans to allow someone to customize their error handling depending on whether the requested version is deprecated or newer than any of the supported versions.