Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONResponse ¶
JSONResponse executes the given HTTP request using the provided HTTPClient, reads the response body, and unmarshal it into a value of type RespType.
Types ¶
type DefaultHTTPClient ¶
DefaultHTTPClient is the default implementation of HTTPClient, which delegates to the standard library http.Client.
func (*DefaultHTTPClient) Do ¶
Do executes the HTTP request using the embedded http.Client. It reads the entire response body into memory and returns both the *http.Response and the body as a byte slice.
The response body is also replaced with a reusable buffer so that it can be read again by the caller if needed.
Note: For very large responses, this may be memory intensive.
type FormProtocol ¶
type FormProtocol struct{}
FormProtocol implements the Protocol interface for the application/x-www-form-urlencoded format.
type HTTPClient ¶
HTTPClient defines a customizable HTTP executor interface. Implementing this interface allows users to provide their own HTTP execution logic (for example, to add retry, logging, or tracing).
type JSONProtocol ¶
type JSONProtocol struct{}
JSONProtocol implements the Protocol interface using JSON encoding.
type Protocol ¶
Protocol defines a common interface for encoding and decoding data into different serialization formats.
var ( // FORM provides an implementation of the Protocol interface using // application/x-www-form-urlencoded encoding. FORM Protocol = &FormProtocol{} // JSON provides an implementation of the Protocol interface using // JSON encoding. JSON Protocol = &JSONProtocol{} )