Documentation ¶
Index ¶
- Constants
- func Connect(url string, opts ...*options.Option) (response.Response, error)
- func Custom(method string, url string, payload any, opts ...*options.Option) (response.Response, error)
- func Delete(url string, opts ...*options.Option) (response.Response, error)
- func Get(url string, opts ...*options.Option) (response.Response, error)
- func Head(url string, opts ...*options.Option) (response.Response, error)
- func Options(url string, opts ...*options.Option) (response.Response, error)
- func Patch(url string, payload any, opts ...*options.Option) (response.Response, error)
- func PatchFile(url string, filename string, opts ...*options.Option) (response.Response, error)
- func PatchFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
- func Post(url string, payload any, opts ...*options.Option) (response.Response, error)
- func PostFile(url string, filename string, opts ...*options.Option) (response.Response, error)
- func PostFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
- func Put(url string, payload any, opts ...*options.Option) (response.Response, error)
- func PutFile(url string, filename string, opts ...*options.Option) (response.Response, error)
- func PutFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
- func Trace(url string, opts ...*options.Option) (response.Response, error)
- type Client
- func (c *Client) AddGlobalOptions(opts *options.Option)
- func (c *Client) Clear()
- func (c *Client) CloneGlobalOptions() *options.Option
- func (c *Client) Connect(url string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Custom(method string, url string, payload any, opts ...*options.Option) (response.Response, error)
- func (c *Client) Delete(url string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Get(url string, opts ...*options.Option) (response.Response, error)
- func (c *Client) GetGlobalOptions() *options.Option
- func (c *Client) Head(url string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Options(url string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Patch(url string, payload any, opts ...*options.Option) (response.Response, error)
- func (c *Client) PatchFile(url string, filename string, opts ...*options.Option) (response.Response, error)
- func (c *Client) PatchFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Post(url string, payload any, opts ...*options.Option) (response.Response, error)
- func (c *Client) PostFile(url string, filename string, opts ...*options.Option) (response.Response, error)
- func (c *Client) PostFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Put(url string, payload any, opts ...*options.Option) (response.Response, error)
- func (c *Client) PutFile(url string, filename string, opts ...*options.Option) (response.Response, error)
- func (c *Client) PutFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
- func (c *Client) Responses() []response.Response
- func (c *Client) Trace(url string, opts ...*options.Option) (response.Response, error)
- func (c *Client) UpdateGlobalOptions(opts *options.Option)
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
Connect performs an HTTP CONNECT to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Custom ¶
func Custom(method string, url string, payload any, opts ...*options.Option) (response.Response, error)
Custom performs a custom HTTP method to the specified URL with the given payload. It accepts the HTTP method as its first argument, the URL string as the second argument, the payload as the third argument, and optionally additional Options to customize the request. Returns the HTTP response and an error if any.
func Delete ¶
Delete performs an HTTP DELETE to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Get ¶
Get performs an HTTP GET to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Head ¶
Head performs an HTTP HEAD to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Options ¶
Options performs an HTTP OPTIONS to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Patch ¶
Patch performs an HTTP PATCH to the specified URL with the given payload. It accepts the URL string as its first argument and the payload as the second argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func PatchFile ¶ added in v1.1.1
PatchFile uploads a file to the specified URL using an HTTP PATCH request. It accepts the URL string as its first argument and the filename as the second argument. The file is read from the specified filename and uploaded as the request payload. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func PatchFormData ¶ added in v1.0.0
func PatchFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
PatchFormData performs an HTTP PATCH as an x-www-form-urlencoded payload to the specified URL. It accepts the URL string as its first argument and a map[string]string the payload. The map is converted to a url.QueryEscaped k/v pair that is sent to the server. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Post ¶
Post performs an HTTP POST to the specified URL with the given payload. It accepts the URL string as its first argument and the payload as the second argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func PostFile ¶ added in v1.1.1
PostFile uploads a file to the specified URL using an HTTP POST request. It accepts the URL string as its first argument and the filename as the second argument. The file is read from the specified filename and uploaded as the request payload. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func PostFormData ¶ added in v1.0.0
func PostFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
PostFormData performs an HTTP POST as an x-www-form-urlencoded payload to the specified URL. It accepts the URL string as its first argument and a map[string]string the payload. The map is converted to a url.QueryEscaped k/v pair that is sent to the server. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func Put ¶
Put performs an HTTP PUT to the specified URL with the given payload. It accepts the URL string as its first argument and the payload as the second argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func PutFile ¶ added in v1.1.1
PutFile uploads a file to the specified URL using an HTTP PUT request. It accepts the URL string as its first argument and the filename as the second argument. The file is read from the specified filename and uploaded as the request payload. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func PutFormData ¶ added in v1.0.0
func PutFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
PutFormData performs an HTTP PUT as an x-www-form-urlencoded payload to the specified URL. It accepts the URL string as its first argument and a map[string]string the payload. The map is converted to a url.QueryEscaped k/v pair that is sent to the server. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an HTTP client.
func New ¶
New returns a reusable Client. It is possible to include a global RequestOptions which will be used on all subsequent requests.
func NewCustom ¶
NewCustom returns a reusable client with a custom defined *http.Client This is useful in scenarios where you want to change any configurations for the http.Client
func (*Client) AddGlobalOptions ¶ added in v0.4.0
AddGlobalOptions adds the provided options to the client's global options
func (*Client) Clear ¶
func (c *Client) Clear()
Clear clears any Responses that have already been made and kept.
func (*Client) CloneGlobalOptions ¶
CloneGlobalOptions clones the global RequestOptions of the client.
func (*Client) Connect ¶
Connect performs an HTTP CONNECT to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Custom ¶
func (c *Client) Custom(method string, url string, payload any, opts ...*options.Option) (response.Response, error)
Custom performs a custom HTTP method to the specified URL with the given payload. It accepts the HTTP method as its first argument, the URL string as the second argument, the payload as the third argument, and optionally additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Delete ¶
Delete performs an HTTP DELETE to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Get ¶
Get performs an HTTP GET to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) GetGlobalOptions ¶
GetGlobalOptions returns the global RequestOptions of the client.
func (*Client) Head ¶
Head performs an HTTP HEAD to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Options ¶
Options performs an HTTP OPTIONS to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Patch ¶
Patch performs an HTTP PATCH to the specified URL with the given payload. It accepts the URL string as its first argument and the payload as the second argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) PatchFile ¶ added in v1.1.1
func (c *Client) PatchFile(url string, filename string, opts ...*options.Option) (response.Response, error)
PatchFile uploads a file to the specified URL using an HTTP PATCH request. It accepts the URL string as its first argument and the filename as the second argument. The file is read from the specified filename and uploaded as the request payload. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) PatchFormData ¶ added in v1.0.0
func (c *Client) PatchFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
PatchFormData performs an HTTP PATCH as an x-www-form-urlencoded payload to the specified URL. It accepts the URL string as its first argument and a map[string]string the payload. The map is converted to a url.QueryEscaped k/v pair that is sent to the server. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Post ¶
Post performs an HTTP POST to the specified URL with the given payload. It accepts the URL string as its first argument and the payload as the second argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) PostFile ¶ added in v1.1.1
func (c *Client) PostFile(url string, filename string, opts ...*options.Option) (response.Response, error)
PostFile uploads a file to the specified URL using an HTTP POST request. It accepts the URL string as its first argument and the filename as the second argument. The file is read from the specified filename and uploaded as the request payload. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) PostFormData ¶ added in v1.0.0
func (c *Client) PostFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
PostFormData performs an HTTP POST as an x-www-form-urlencoded payload to the specified URL. It accepts the URL string as its first argument and a map[string]string the payload. The map is converted to a url.QueryEscaped k/v pair that is sent to the server. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Put ¶
Put performs an HTTP PUT to the specified URL with the given payload. It accepts the URL string as its first argument and the payload as the second argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) PutFile ¶ added in v1.1.1
func (c *Client) PutFile(url string, filename string, opts ...*options.Option) (response.Response, error)
PutFile uploads a file to the specified URL using an HTTP PUT request. It accepts the URL string as its first argument and the filename as the second argument. The file is read from the specified filename and uploaded as the request payload. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) PutFormData ¶ added in v1.0.0
func (c *Client) PutFormData(url string, payload map[string]string, opts ...*options.Option) (response.Response, error)
PutFormData performs an HTTP PUT as an x-www-form-urlencoded payload to the specified URL. It accepts the URL string as its first argument and a map[string]string the payload. The map is converted to a url.QueryEscaped k/v pair that is sent to the server. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) Responses ¶ added in v0.2.0
Responses returns a slice of responses made by this Client
func (*Client) Trace ¶
Trace performs an HTTP TRACE to the specified URL. It accepts the URL string as its first argument. Optionally, you can provide additional Options to customize the request. Returns the HTTP response and an error if any.
func (*Client) UpdateGlobalOptions ¶
UpdateGlobalOptions updates the global RequestOptions of the client.