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 MultipartUpload(method, url string, payload map[string]any, 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 PatchMultipartUpload(url string, payload map[string]interface{}, 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 PostMultipartUpload(url string, payload map[string]interface{}, 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 PutMultipartUpload(url string, payload map[string]interface{}, 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 MultipartUpload ¶
func MultipartUpload(method, url string, payload map[string]any, opts ...*options.Option) (response.Response, error)
MultipartUpload performs a multipart form-data upload request to the specified URL. It supports file uploads and other form fields.
Parameters:
- method: The HTTP method to use for the request (e.g., "POST", "PUT", "PATCH").
- url: The target URL for the upload.
- payload: A map containing the form fields and file pointers to upload. For file uploads, use *os.File as the value.
- opts: Optional parameters for the request (e.g., headers, timeout).
Returns:
- response.Response: The response from the server.
- error: Any error encountered during the request.
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 ¶
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 ¶
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 PatchMultipartUpload ¶
func PatchMultipartUpload(url string, payload map[string]interface{}, opts ...*options.Option) (response.Response, error)
PatchMultipartUpload performs a PATCH multipart form-data upload request to the specified URL. This method can be used for partial updates to a resource, which might include updating or adding new file attachments.
Parameters:
- url: The target URL for the upload.
- payload: A map containing the form fields and file pointers to upload. For file uploads, use *os.File as the value.
- opts: Optional parameters for the request (e.g., headers, timeout).
Returns:
- response.Response: The response from the server.
- error: Any error encountered during the request.
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 ¶
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 ¶
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 PostMultipartUpload ¶
func PostMultipartUpload(url string, payload map[string]interface{}, opts ...*options.Option) (response.Response, error)
PostMultipartUpload performs a POST multipart form-data upload request to the specified URL. This is the most common method for file uploads and creating new resources with file attachments.
Parameters:
- url: The target URL for the upload.
- payload: A map containing the form fields and file pointers to upload. For file uploads, use *os.File as the value.
- opts: Optional parameters for the request (e.g., headers, timeout).
Returns:
- response.Response: The response from the server.
- error: Any error encountered during the request.
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 ¶
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 ¶
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.
func PutMultipartUpload ¶
func PutMultipartUpload(url string, payload map[string]interface{}, opts ...*options.Option) (response.Response, error)
PutMultipartUpload performs a PUT multipart form-data upload request to the specified URL. This method is less common but can be used when updating an entire resource with new data, including file attachments.
Parameters:
- url: The target URL for the upload.
- payload: A map containing the form fields and file pointers to upload. For file uploads, use *os.File as the value.
- opts: Optional parameters for the request (e.g., headers, timeout).
Returns:
- response.Response: The response from the server.
- error: Any error encountered during the request.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) 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.