Documentation ¶
Index ¶
- Variables
- type APIClientConfig
- type Client
- type Config
- type Request
- func (r *Request) Delete(url string) (context.CancelFunc, *resty.Response, error)
- func (r *Request) EnableTrace() *Request
- func (r *Request) Execute(method, url string) (context.CancelFunc, *resty.Response, error)
- func (r *Request) ExpectContentType(contentType string) *Request
- func (r *Request) ForceContentType(contentType string) *Request
- func (r *Request) Get(url string) (context.CancelFunc, *resty.Response, error)
- func (r *Request) Post(url string) (context.CancelFunc, *resty.Response, error)
- func (r *Request) Put(url string) (context.CancelFunc, *resty.Response, error)
- func (r *Request) SetAuthScheme(scheme string) *Request
- func (r *Request) SetAuthToken(token string) *Request
- func (r *Request) SetBasicAuth(username, password string) *Request
- func (r *Request) SetBody(body interface{}) *Request
- func (r *Request) SetContentLength(l bool) *Request
- func (r *Request) SetContext(ctx context.Context) *Request
- func (r *Request) SetCookie(hc *http.Cookie) *Request
- func (r *Request) SetCookies(rs []*http.Cookie) *Request
- func (r *Request) SetDoNotParseResponse(parse bool) *Request
- func (r *Request) SetError(err interface{}) *Request
- func (r *Request) SetFile(param, filePath string) *Request
- func (r *Request) SetFileReader(param, fileName string, reader io.Reader) *Request
- func (r *Request) SetFiles(files map[string]string) *Request
- func (r *Request) SetFormData(data map[string]string) *Request
- func (r *Request) SetFormDataFromValues(data url.Values) *Request
- func (r *Request) SetHeader(header, value string) *Request
- func (r *Request) SetHeaderVerbatim(header, value string) *Request
- func (r *Request) SetHeaders(headers map[string]string) *Request
- func (r *Request) SetJSONEscapeHTML(b bool) *Request
- func (r *Request) SetJSONResult(res interface{}) *Request
- func (r *Request) SetMultipartField(param, fileName, contentType string, reader io.Reader) *Request
- func (r *Request) SetMultipartFields(fields ...*resty.MultipartField) *Request
- func (r *Request) SetMultipartFormData(data map[string]string) *Request
- func (r *Request) SetOutput(file string) *Request
- func (r *Request) SetPathParam(param, value string) *Request
- func (r *Request) SetPathParams(params map[string]string) *Request
- func (r *Request) SetQueryParam(param, value string) *Request
- func (r *Request) SetQueryParams(params map[string]string) *Request
- func (r *Request) SetQueryParamsFromValues(params url.Values) *Request
- func (r *Request) SetQueryString(query string) *Request
- func (r *Request) SetSRV(srv *resty.SRVRecord) *Request
- func (r *Request) SetTimeout(timeout time.Duration) *Request
- func (r *Request) TraceInfo() resty.TraceInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrNS = errorx.NewNamespace("http_client") ErrInvalidEndpoint = ErrNS.NewType("invalid_endpoint") ErrServerError = ErrNS.NewType("server_error") )
Functions ¶
This section is empty.
Types ¶
type APIClientConfig ¶
type APIClientConfig struct { // Endpoint is required in format `http(s)://host:port`. // If TLS is specified, `http://` will be updated to `https://`. Endpoint string Context context.Context TLS *tls.Config }
func (APIClientConfig) IntoConfig ¶
func (dc APIClientConfig) IntoConfig(kindTag string) (Config, error)
type Client ¶
Client is a lightweight wrapper over resty.Client, providing default error handling and timeout settings. WARN: This structure is not thread-safe.
func (*Client) LifecycleR ¶
LifecycleR builds a new Request with the default lifecycle context and the default timeout. This function is intentionally not named as `R()` to avoid being confused with `resty.Client.R()`.
type Request ¶
Request is a lightweight wrapper over resty.Request. Different to resty.Request, it enforces a timeout. WARN: This structure is not thread-safe.
func (*Request) Delete ¶
func (r *Request) Delete(url string) (context.CancelFunc, *resty.Response, error)
WARN: The returned cancelFunc must be called to avoid context leak.
func (*Request) EnableTrace ¶
func (*Request) Execute ¶
func (r *Request) Execute(method, url string) (context.CancelFunc, *resty.Response, error)
WARN: The returned cancelFunc must be called to avoid context leak.
func (*Request) ExpectContentType ¶
func (*Request) ForceContentType ¶
func (*Request) Get ¶
func (r *Request) Get(url string) (context.CancelFunc, *resty.Response, error)
WARN: The returned cancelFunc must be called to avoid context leak.
func (*Request) Post ¶
func (r *Request) Post(url string) (context.CancelFunc, *resty.Response, error)
WARN: The returned cancelFunc must be called to avoid context leak.
func (*Request) Put ¶
func (r *Request) Put(url string) (context.CancelFunc, *resty.Response, error)
WARN: The returned cancelFunc must be called to avoid context leak.
func (*Request) SetAuthScheme ¶
func (*Request) SetAuthToken ¶
func (*Request) SetBasicAuth ¶
func (*Request) SetContentLength ¶
func (*Request) SetDoNotParseResponse ¶
func (*Request) SetFileReader ¶
func (*Request) SetFormDataFromValues ¶
func (*Request) SetHeaderVerbatim ¶
func (*Request) SetJSONEscapeHTML ¶
func (*Request) SetJSONResult ¶
SetJSONResult expects a JSON response from the remote endpoint and specify how response is deserialized.