Handle Response objects in cache resolution and in RESTful responses#164
Open
Handle Response objects in cache resolution and in RESTful responses#164
Response objects in cache resolution and in RESTful responses#164Conversation
ae1d27e to
6693cfb
Compare
Response objects in cache resolution and in RESTful responses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This provides improved handling of
ResponseandResponse-like objects in cache resolution and REST responses, addressing CORE-2576 and CORE-2596. This is intended to make easier to setup direct/transparent HTTP caching with minimal work, as simple as:The cache resolution should properly handle the
Responseobject, branching on status codes, storing headers, and if the response is something that can be parsed, is stored in structured data format, if not, it is stored in a blob.There are more expansive ways this can be used to define your headers and data and such, and example usages can be seen in the testApp/resources.js that is used by the tests.
This also broadens the types of responses that the REST handler will treat differently. Previously only a combination of
statusandheadersproperties triggered special response handling, but now the REST handler will honor any object withheadersproperties as having headers that should be returned in the response (along with more granular logic fordata/body). It actually should be more common (or encouraged) to returnheadersthanstatus.Also this introduces ambient access to the current "response" object, allowing code to generally set response headers or status like:
Thoughts on the ergonomics of this are certainly welcome also.