Last active
October 19, 2017 14:40
-
-
Save trezy/86d22bfc3c7bc066b0e108e7796c8c15 to your computer and use it in GitHub Desktop.
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
| function etag(options) { | |
| return function etag(ctx, next) { | |
| return next() | |
| // `getResponseEntity` checks to see if the response has a body, and | |
| // stringifies it depending on what kind of body it has (JSON, HTML, | |
| // image, etc) | |
| .then(() => getResponseEntity(ctx)) | |
| // `setEtag` calculates the ETag from the response body if it exists, | |
| // then sets that ETag as a header | |
| .then(entity => setEtag(ctx, entity, options)); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment