apiclient: support non-JSON responses via ResponseType - #5939
Merged
Conversation
Adds a ResponseType field on RequestParams so callers can opt out of JSON decoding and receive the raw response body (e.g. for scraping stellar.toml at /.well-known/stellar.toml). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in ResponseType on utils/apiclient.RequestParams to allow callers to bypass JSON decoding and receive the raw response body (useful for non-JSON endpoints like /.well-known/stellar.toml), while preserving the existing default JSON behavior.
Changes:
- Extend
RequestParamswithResponseTypeand introduceResponseTypeJSON/ResponseTypeRawconstants. - Update
APIClient.CallAPIto switch response handling between JSON unmarshal (default) and raw[]byte. - Expand
CallAPItests to cover raw responses, invalid JSON under JSON mode, and unsupported response types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| utils/apiclient/main.go | Adds ResponseType to request params and defines supported response type constants. |
| utils/apiclient/client.go | Implements response decoding selection (JSON vs raw) based on ResponseType. |
| utils/apiclient/client_test.go | Adds coverage for raw body returns and response type validation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chowbao
reviewed
May 6, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
chowbao
approved these changes
May 6, 2026
urvisavla
pushed a commit
that referenced
this pull request
May 28, 2026
* apiclient: support non-JSON responses via ResponseType Adds a ResponseType field on RequestParams so callers can opt out of JSON decoding and receive the raw response body (e.g. for scraping stellar.toml at /.well-known/stellar.toml). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * apiclient: normalize ResponseType to default JSON Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.
Adds a
ResponseTypefield onRequestParamsso callers can opt out of JSON decoding and receive the raw response body — needed for scraping non-JSON endpoints like/.well-known/stellar.toml.Default behavior is unchanged (JSON).