Skip to content

apiclient: support non-JSON responses via ResponseType - #5939

Merged
amishas157 merged 3 commits into
mainfrom
apiclient/support-non-json-response
May 6, 2026
Merged

apiclient: support non-JSON responses via ResponseType#5939
amishas157 merged 3 commits into
mainfrom
apiclient/support-non-json-response

Conversation

@amishas157

@amishas157 amishas157 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Adds a ResponseType field on RequestParams so 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).

amishas157 and others added 2 commits April 24, 2026 15:53
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]>
@amishas157
amishas157 marked this pull request as ready for review May 6, 2026 20:51
Copilot AI review requested due to automatic review settings May 6, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RequestParams with ResponseType and introduce ResponseTypeJSON / ResponseTypeRaw constants.
  • Update APIClient.CallAPI to switch response handling between JSON unmarshal (default) and raw []byte.
  • Expand CallAPI tests 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.

Comment thread utils/apiclient/client.go Outdated
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@amishas157
amishas157 merged commit d170348 into main May 6, 2026
11 checks passed
@amishas157
amishas157 deleted the apiclient/support-non-json-response branch May 6, 2026 21:55
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]>
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.

3 participants