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

chore: allow fully overriding response body bytes in Modifier #41

Conversation

dmitryabramov-f3
Copy link
Contributor

@dmitryabramov-f3 dmitryabramov-f3 commented Jul 25, 2023

Currently pact-proxy is using https://github.com/tidwall/sjson to modify response body which allows overriding only specific keys in response body JSON, but not the whole body. The use case is to be able to dynamically modify some plain text responses, for example by specifying it as base64 encoded bytes.

This PR adds a handling for a special case path == "$.bytes.body" to override the whole body with the provided value. In this case bytes body will be passed base64 encoded so we have to base64 decode it.

Also add error handling when json.Marshal does not work on AddModifier in the client package.

@dmitryabramov-f3 dmitryabramov-f3 requested a review from a team as a code owner July 25, 2023 17:37
@dmitryabramov-f3 dmitryabramov-f3 force-pushed the dabramov-allow-overriding-full-response-body branch from 99c10e1 to 5f7c02d Compare July 26, 2023 10:40
@dmitryabramov-f3 dmitryabramov-f3 changed the title chore: allow fully overriding response body in Modifier chore: allow fully overriding response body bytes in Modifier Jul 26, 2023
@miketonks-form3 miketonks-form3 merged commit 17350fa into form3tech-oss:master Jul 26, 2023
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

Successfully merging this pull request may close these issues.

2 participants