Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizationOptions ¶
type AuthorizationOptions interface {
Bearer() string
SetBearer(bearer string)
Basic() BasicAuthorizationOptions
SetBasic(basic BasicAuthorizationOptions)
}
type Client ¶
type Client interface {
Get(urlString string, options ...RequestOption) (Response, error)
Post(urlString string, body any, options ...RequestOption) (Response, error)
Put(urlString string, body any, options ...RequestOption) (Response, error)
Patch(urlString string, body any, options ...RequestOption) (Response, error)
Delete(urlString string, options ...RequestOption) (Response, error)
Request(method string, urlString string, options ...RequestOption) (Response, error)
/* RequestStream hands back a response whose body is still open. The caller closes it on every path — the streaming path carries no whole-request deadline, so a stream left unclosed holds its connection for the life of the process. */
RequestStream(method string, urlString string, options ...RequestOption) (StreamResponse, error)
}
type RequestOption ¶
type RequestOption func(RequestOptions)
type RequestOptions ¶
type RequestOptions interface {
Headers() map[string]string
Query() map[string]string
Body() any
ContentType() string
Timeout() time.Duration
Authorization() AuthorizationOptions
MaxResponseBodyBytes() int
SetMaxResponseBodyBytes(maxResponseBodyBytes int)
SetHeader(key string, value string)
SetHeaders(headers map[string]string)
SetQuery(key string, value string)
SetQueryParams(parameters map[string]string)
SetBody(body any)
SetJson(data any)
SetTimeout(timeout time.Duration)
SetBearerToken(token string)
SetBasicAuth(username string, password string)
}
type StreamResponse ¶
type StreamResponse interface {
StatusCode() int
Headers() nethttp.Header
/* Body is the live body. After Close it reads as a failure rather than a nil reader, so a consumer racing a watchdog gets an error instead of a nil dereference. */
Body() io.ReadCloser
Close() error
}
StreamResponse is a response whose body is still on the wire. The caller owns it: Close it on every path, including the ones that never read the body, because the connection behind it is released by nothing else.
Click to show internal directories.
Click to hide internal directories.