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

Flag to sort the request body by key names #8

Closed
arzmir opened this issue Jul 16, 2018 · 3 comments
Closed

Flag to sort the request body by key names #8

arzmir opened this issue Jul 16, 2018 · 3 comments

Comments

@arzmir
Copy link

arzmir commented Jul 16, 2018

Possibly Covered In Issue #7

Your proposal on how to handle partial body matching might also cover this issue. As one could maybe supply a deep match or body sorting function.

Problem

During some readability refactoring I wanted to sort some lines of code alphabetically, but because these were setting values for a request payload, it caused a cache miss in Talkback.

What I assume is the issue here is the payload object is unsorted when stringified. Which probably is in everyones interest for most situations in a performance perspective. But here it causes a cache miss for equal data with different ordering.

Working around the issue is no worse than rebuilding the Talkback request-response pair, but it may be tedious for bigger rounds of refactoring.

Proposal

A configuration flag for choosing to sort the body by key names. Opting for a flag as It will undoubtedly be a performance hit.

Flag Name Value Description Default
sortRequestBody Boolean Whether or not to sort the request body before building a cache. This removes the need for specific ordering in request payloads. false
@ijpiantanida
Copy link
Owner

Hi @arzmir.
As you mentioned, for now I'd cover this scenario with my proposal of leaving this to the user by providing a custom bodymatcher function (should be out soon).

I'm trying to avoid having to parse the body contents, if possible.

Thank you for the idea though!

@ijpiantanida
Copy link
Owner

@arzmir I just release v1.5.0, which adds the bodyMatcher option.
There's an example on how to use it in the README.

Hope it helps!

@arzmir
Copy link
Author

arzmir commented Jul 18, 2018

Wonderful. Will take it for a test run soon.

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

No branches or pull requests

2 participants