Documentation
¶
Index ¶
- Constants
- type HTTPError
- type Http
- func (h *Http) Delete(ctx context.Context, path string, out interface{}) (int, error)
- func (h *Http) FireAndForget(ctx context.Context, method, path string, body interface{})
- func (h *Http) Get(ctx context.Context, path string, out interface{}) (int, error)
- func (h *Http) Patch(ctx context.Context, path string, body, out interface{}) (int, error)
- func (h *Http) Post(ctx context.Context, path string, body, out interface{}) (int, error)
- func (h *Http) Put(ctx context.Context, path string, body, out interface{}) (int, error)
- func (h *Http) SetHeader(key, value string)
- type Option
Constants ¶
const ( Post = fasthttp.MethodPost Get = fasthttp.MethodGet Put = fasthttp.MethodPut Patch = fasthttp.MethodPatch Delete = fasthttp.MethodDelete Options = fasthttp.MethodOptions Head = fasthttp.MethodHead Connect = fasthttp.MethodConnect Trace = fasthttp.MethodTrace )
HTTP method constants re-exported from fasthttp for use with Http.FireAndForget and similar helpers.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Http ¶
type Http struct {
BaseURL string
Client *fasthttp.Client
// contains filtered or unexported fields
}
Http is a small JSON HTTP client built on fasthttp.
func (*Http) FireAndForget ¶
FireAndForget sends a request in the background, logging any error if a logger was configured via WithLogger. The caller's context values are kept but its cancellation/deadline are dropped so the request outlives the caller.
func (*Http) Patch ¶
Patch sends a PATCH request with a JSON-encoded body and decodes the response into out.
func (*Http) Post ¶
Post sends a POST request with a JSON-encoded body and decodes the response into out.
type Option ¶
type Option func(*Http)
Option configures an Http client.
func WithClient ¶
WithClient replaces the underlying fasthttp client.
func WithHeader ¶
WithHeader adds a default header sent with every request.
func WithLogger ¶
WithLogger attaches a logger used to report FireAndForget errors.
func WithRetry ¶
WithRetry configures the number of additional retry attempts and the backoff duration between them. Only 5xx errors and transport failures are retried.
func WithTimeout ¶
WithTimeout sets the per-request timeout used when no context deadline is present.