Documentation ¶
Index ¶
- Variables
- type APIClient
- func (c *APIClient) ChangeRequest(cb func(rq *http.Request)) *APIClient
- func (c *APIClient) Delete(url string) *APIClient
- func (c *APIClient) Do(cb func(resp *http.Response))
- func (c *APIClient) DoDecodeTo(decodeTo interface{}, encoding Encoding, ...)
- func (c *APIClient) Get(url string) *APIClient
- func (c *APIClient) NoRecover() *APIClient
- func (c *APIClient) OnError(cb func(err error) bool) *APIClient
- func (c *APIClient) Patch(url string) *APIClient
- func (c *APIClient) Post(url string) *APIClient
- func (c *APIClient) Put(url string) *APIClient
- func (c *APIClient) WithCookie(cookie *http.Cookie) *APIClient
- func (c *APIClient) WithData(formData map[string]string, encoding Encoding, file ...File) *APIClient
- func (c *APIClient) WithHeaders(headers map[string]string) *APIClient
- func (c *APIClient) WithQuery(query map[string]string) *APIClient
- type Encoding
- type File
- type Methods
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoRequest = "no request has been set" // Error message for when no request has been set ErrNoCallback = "no callback has been set" // Error message for when no callback has been set ErrNoEncoding = "no encoding has been set or is not valid" // Error message for when no encoding has been set )
Define standard error messages
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient is a client that can be used to execute http requests. - Can be used to execute GET, POST, PUT, DELETE, PATCH requests.
func NewAPIClient ¶
func NewAPIClient() *APIClient
APIClient is a client that can be used to make requests to a server.
func (*APIClient) ChangeRequest ¶
Change the request before it is made This is useful for adding headers, cookies, etc.
func (*APIClient) DoDecodeTo ¶
func (c *APIClient) DoDecodeTo(decodeTo interface{}, encoding Encoding, cb func(resp *http.Response, strct interface{}))
Make a request and return the response body decoded into the specified parameter. -> APIClient.Do -> APIClient.exec
func (*APIClient) WithCookie ¶
Add a HTTP.Cookie to the request
func (*APIClient) WithData ¶
func (c *APIClient) WithData(formData map[string]string, encoding Encoding, file ...File) *APIClient
Add form data to the request
func (*APIClient) WithHeaders ¶
Add headers to the request
type File ¶
type File struct { FileName string // Name of the file FieldName string // Name of the field Reader io.Reader // Reader of the file }
Define a type for multipart files
type Methods ¶
type Methods string
Define methods and encodings type
const ( GET Methods = "GET" // GET method POST Methods = "POST" // POST method PUT Methods = "PUT" // PUT method PATCH Methods = "PATCH" // PATCH method DELETE Methods = "DELETE" // DELETE method OPTIONS Methods = "OPTIONS" // OPTIONS method HEAD Methods = "HEAD" // HEAD method TRACE Methods = "TRACE" // TRACE method )
Define request methods
Click to show internal directories.
Click to hide internal directories.