Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrJSON = "httpclient: json error decoding response" ErrJSON2 = "httpclient: json error decoding error response" ErrRequest = "httpclient: error creating http request" ErrStatus = "httpclient: http.Status not OK" )
Variables ¶
View Source
var Client http.Client
Functions ¶
func GetJSON ¶ added in v0.2.0
func GetJSON[T any, R any](data any, resp T, errResponse R, method, url, auth string, headers []Header) (T, R, error)
JSON returns JSON response from http request if response.code is http.StatusOK (200) returns resp, nil, nil if response.code is not http.Status ok returns nil, errResponse, ErrStatus if json decode err returns nil, nil, err set to 'json decode err' for any other err returns nil, nil, err
Types ¶
type Endpoint ¶
type Endpoint struct {
URL string
Method string
Route string
Authorization string
Headers []Header
Data any
}
Endpoint struct for an http endpoint
type ErrHttpClient ¶ added in v0.6.1
ErrHttpClient error stuct
func (ErrHttpClient) Error ¶ added in v0.6.1
func (e ErrHttpClient) Error() string
ErrHttpClient.Error implementation of error interface
type JSONEndpoint ¶ added in v0.3.0
type JSONEndpoint[T any, R any] struct { URL string Method string Route string Authorization string Headers []Header Data any Response T ErrorResponse R }
func (*JSONEndpoint[T, R]) GetJSON ¶ added in v0.3.0
func (e *JSONEndpoint[T, R]) GetJSON(response T, errResponse R) (T, R, error)
GetJSON returns JSON received from http endpoint
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
functions/json
command
|
|
|
functions/response
command
|
|
|
method/json
command
|
|
|
method/response
command
|
Click to show internal directories.
Click to hide internal directories.