Documentation
¶
Index ¶
- func Fake(mocks map[string]*Response)
- type Client
- func (c *Client) BaseURL(url string) *Client
- func (c *Client) Delete(path string) (*Response, error)
- func (c *Client) Get(path string) (*Response, error)
- func (c *Client) Head(path string) (*Response, error)
- func (c *Client) Patch(path string, data any) (*Response, error)
- func (c *Client) Post(path string, data any) (*Response, error)
- func (c *Client) PostForm(path string, data map[string]string) (*Response, error)
- func (c *Client) Put(path string, data any) (*Response, error)
- func (c *Client) Retry(times int) *Client
- func (c *Client) WithHeader(key, value string) *Client
- func (c *Client) WithHeaders(headers map[string]string) *Client
- func (c *Client) WithQuery(key, value string) *Client
- func (c *Client) WithToken(token string) *Client
- type Response
- func (r *Response) Body() []byte
- func (r *Response) ClientError() bool
- func (r *Response) Failed() bool
- func (r *Response) Header(key string) string
- func (r *Response) JSON(target any) error
- func (r *Response) Ok() bool
- func (r *Response) ServerError() bool
- func (r *Response) StatusCode() int
- func (r *Response) Successful() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a standard HTTP client and provides fluent request building.
func (*Client) WithHeader ¶
WithHeader adds a header to the client.
func (*Client) WithHeaders ¶
WithHeaders sets multiple headers at once.
type Response ¶
Response wraps an HTTP response with many convenient helpers.
func (*Response) ClientError ¶
ClientError returns true for 4xx responses.
func (*Response) ServerError ¶
ServerError returns true for 5xx responses.
func (*Response) StatusCode ¶
StatusCode returns the HTTP status code.
Click to show internal directories.
Click to hide internal directories.