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
Support $.request.hash template #315
Conversation
delete context.request.headers['x-request-id']; | ||
} | ||
|
||
var result = sha1(stringify(context.request)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should ensure consistent hashing. That means checking for standard request components (uri, headers, body, query) so as to avoid different hashes in situations where some are missing. E.g., these two requests will yield different hashes even though they should be treated equally:
request1:
uri: /a/simple/path
headers: {}
body: ''
request2:
uri: /a/simple/path
body: {}
req.params = req.params || {}; | ||
|
||
// Need to remove x-request-id header if it's present | ||
var reqId = req.headers && req.headers['x-request-id']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary to check for req.headers
now that we ensure the property exists.
It might be cleaner to implement this as a thin wrapper module on top of a key_value bucket, perhaps |
@gwicke Yes, that's true, we've got out of the original plan. I will update the PR to implement a post_data module. |
Actually, the new approach is completely different and not related to this PR, so I'd better close this one and create a new one with |
A simple fix to support calculation of
'{$.request.hash}'
templates to calculate hashes of the request.