Documentation ¶
Index ¶
- Variables
- func SetDefaultTimeout(Timeout time.Duration)
- type Batch
- type BatchMapper
- type Parser
- type Request
- func (r *Request) Bytes(Data []byte) *Request
- func (r *Request) Header(key string, value string) *Request
- func (r *Request) JSON(Data interface{}) *Request
- func (r *Request) MultipartForm(Buffer *bytes.Buffer, ContentType string) *Request
- func (r *Request) Plugin(Function func(r *Request)) *Request
- func (r *Request) Query(Key string, Value string) *Request
- func (r *Request) Reader(Data io.Reader) *Request
- func (r *Request) Run() (*Response, error)
- func (r *Request) Serialize(data interface{}, serializer Serializer) *Request
- func (r *Request) Timeout(Value time.Duration) *Request
- func (r *Request) URLEncodedForm(Data url.Values) *Request
- type Response
- type RouteHandler
- func (r *RouteHandler) DELETE(Path string) *Request
- func (r *RouteHandler) GET(Path string) *Request
- func (r *RouteHandler) GenerateURL(Path string) (string, error)
- func (r *RouteHandler) HEAD(Path string) *Request
- func (r *RouteHandler) OPTIONS(Path string) *Request
- func (r *RouteHandler) PATCH(Path string) *Request
- func (r *RouteHandler) POST(Path string) *Request
- func (r *RouteHandler) PUT(Path string) *Request
- type Serializer
Constants ¶
This section is empty.
Variables ¶
var DefaultTimeout = time.Duration(0)
DefaultTimeout defines the default timeout.
Functions ¶
func SetDefaultTimeout ¶
SetDefaultTimeout allows the user to set the default timeout in this library.
Types ¶
type Batch ¶
type Batch []*Request
Batch is used to define a request batch.
type BatchMapper ¶
type BatchMapper struct {
// contains filtered or unexported fields
}
BatchMapper is used to handle mapping a Batch to values.
func (*BatchMapper) All ¶
func (b *BatchMapper) All() ([]interface{}, error)
All is used to execute a batch job and return the mapped responses. If one fails, the first error is returned.
func (*BatchMapper) Map ¶
func (b *BatchMapper) Map(f func(interface{}) (interface{}, error)) *BatchMapper
Map is used to handle adding a mapper function to the chain.
type Request ¶
type Request struct { URL string `json:"url"` Method string `json:"method"` Headers map[string]string `json:"headers"` CurrentTimeout *time.Duration `json:"timeout"` CurrentReader io.Reader `json:"-"` Error *error `json:"-"` }
Request defines the request that will be ran.
func (*Request) MultipartForm ¶
MultipartForm sets the data to a multipart form.
func (*Request) Serialize ¶
func (r *Request) Serialize(data interface{}, serializer Serializer) *Request
Serialize sets response headers and calls Bytes with the serialized body.
type Response ¶
Response defines the higher level HTTP response.
func (*Response) JSON ¶
JSON returns the result as a interface which can be converted how the user wishes.
func (*Response) JSONToPointer ¶
JSONToPointer is used to be a non-generic JSON handler when you have a pointer.
func (*Response) RaiseForStatus ¶
RaiseForStatus throws a error if the request is a 4XX/5XX.
type RouteHandler ¶
type RouteHandler struct { BaseURL string `json:"base_url"` Timeout *time.Duration `json:"-"` Headers map[string]string `json:"headers"` }
RouteHandler defines the base HTTP URL/timeout which is used for routes.
func (*RouteHandler) DELETE ¶
func (r *RouteHandler) DELETE(Path string) *Request
DELETE does a DELETE request based on this base.
func (*RouteHandler) GET ¶
func (r *RouteHandler) GET(Path string) *Request
GET does a GET request based on this base.
func (*RouteHandler) GenerateURL ¶
func (r *RouteHandler) GenerateURL(Path string) (string, error)
GenerateURL takes a path and returns the URL with the path added.
func (*RouteHandler) HEAD ¶
func (r *RouteHandler) HEAD(Path string) *Request
HEAD does a HEAD request based on this base.
func (*RouteHandler) OPTIONS ¶
func (r *RouteHandler) OPTIONS(Path string) *Request
OPTIONS does a OPTIONS request based on this base.
func (*RouteHandler) PATCH ¶
func (r *RouteHandler) PATCH(Path string) *Request
PATCH does a PATCH request based on this base.
func (*RouteHandler) POST ¶
func (r *RouteHandler) POST(Path string) *Request
POST does a POST request based on this base.
func (*RouteHandler) PUT ¶
func (r *RouteHandler) PUT(Path string) *Request
PUT does a PUT request based on this base.
type Serializer ¶
Serializer is a request body serializer.