Documentation
¶
Overview ¶
Commands for interacting with HTTP resources
Index ¶
- type Commands
- func (self *Commands) Defaults(args *RequestArgs) error
- func (self *Commands) Delete(url string, args *RequestArgs) (*HttpResponse, error)
- func (self *Commands) Get(url string, args *RequestArgs) (*HttpResponse, error)
- func (self *Commands) Head(url string, args *RequestArgs) (*HttpResponse, error)
- func (self *Commands) Options(url string, args *RequestArgs) (*HttpResponse, error)
- func (self *Commands) Post(url string, args *RequestArgs) (*HttpResponse, error)
- func (self *Commands) Put(url string, args *RequestArgs) (*HttpResponse, error)
- type HttpResponse
- type RequestArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commands ¶
func (*Commands) Defaults ¶
func (self *Commands) Defaults(args *RequestArgs) error
Set default options that apply to all subsequent HTTP requests.
func (*Commands) Delete ¶
func (self *Commands) Delete(url string, args *RequestArgs) (*HttpResponse, error)
Perform an HTTP DELETE request.
func (*Commands) Get ¶
func (self *Commands) Get(url string, args *RequestArgs) (*HttpResponse, error)
Perform an HTTP GET request.
func (*Commands) Head ¶
func (self *Commands) Head(url string, args *RequestArgs) (*HttpResponse, error)
Perform an HTTP HEAD request.
func (*Commands) Options ¶
func (self *Commands) Options(url string, args *RequestArgs) (*HttpResponse, error)
Perform an HTTP OPTIONS request.
func (*Commands) Post ¶
func (self *Commands) Post(url string, args *RequestArgs) (*HttpResponse, error)
Perform an HTTP POST request.
func (*Commands) Put ¶
func (self *Commands) Put(url string, args *RequestArgs) (*HttpResponse, error)
Perform an HTTP PUT request.
type HttpResponse ¶
type HttpResponse struct {
// The numeric HTTP status code of the response.
Status int `json:"status"`
// A textual description of the HTTP response code.
StatusText string `json:"status_text"`
// The time (in millisecond) that the request took to complete.
Took int64 `json:"took"`
// Response headers sent back from the server.
Headers map[string]interface{} `json:"headers"`
// The MIME type of the response body (if any).
ContentType string `json:"type"`
// The length of the response body in bytes.
Length int64 `json:"length"`
// The decoded response body (if any).
Body interface{} `json:"body"`
// If the response status is considered an error, and errors aren't fatal, this will be true.
Error bool `json:"error"`
}
type RequestArgs ¶
type RequestArgs struct {
// The headers to send with the request.
Headers map[string]interface{} `json:"headers"`
// Query string parameters to add to the request.
Params map[string]interface{} `json:"params"`
// A map of cookie key=value pairs to include in the request.
Cookies map[string]interface{} `json:"cookies"`
// The amount of time to wait for the request to complete.
Timeout time.Duration `json:"timeout" default:"30s"`
// The body of the request. This is processed according to what is specified in RequestType.
Body interface{} `json:"body"`
// The type of data in Body, specifying how it should be encoded. Valid values are "raw", "form", and "json"
RequestType string `json:"request_type,omitempty" default:"json"`
// Specify how the response body should be decoded. Can be "raw", or a MIME type that overrides the Content-Type response header.
ResponseType string `json:"response_type,omitempty"`
// Whether to disable TLS peer verification.
DisableVerifySSL bool `json:"disable_verify_ssl"`
// The path to the root TLS CA bundle to use for verifying peer certificates.
CertificateBundle string `json:"ca_bundle"`
// A comma-separated list of numbers (e.g.: 200) or inclusive number ranges (e.g. 200-399) specifying HTTP statuses that are
// expected and non-erroneous.
Statuses string `json:"statuses" default:"200-299"`
// Whether to continue execution if an error status is encountered.
ContinueOnError bool `json:"continue_on_error"`
// Specify that absolutely no processing should be done on the response body.
RawBody bool `json:"raw"`
}
func (*RequestArgs) Merge ¶
func (self *RequestArgs) Merge(other *RequestArgs) *RequestArgs
Click to show internal directories.
Click to hide internal directories.