Documentation ¶
Overview ¶
Example ¶
var body interface{} err := Get("path/to/some/resource"). Header("X-Some-Header", "value"). Send(). ExpectSuccess(). GetJSON(&body). Done() if err != nil { // handle error } // do something with body
Output:
Index ¶
- type Next
- type Request
- func (r *Request) BasicAuth(username, password string) *Request
- func (r *Request) Body(value *bytes.Buffer) *Request
- func (r *Request) Header(key, value string) *Request
- func (r *Request) JSONBody(value interface{}) *Request
- func (r *Request) MarshalJSON() ([]byte, error)
- func (r *Request) MultipartBody(form *questmultipart.Form) *Request
- func (r *Request) Param(key, value string) *Request
- func (r *Request) QueryParam(key, value string) *Request
- func (r *Request) Send() *Response
- func (r *Request) UnmarshalJSON(b []byte) error
- func (r *Request) WithContext(ctx context.Context) *Request
- func (r *Request) WithTransport(transport *http.Transport) *Request
- type Response
- func (r *Response) Done() error
- func (r *Response) ExpectHeader(key, value string) *Response
- func (r *Response) ExpectStatusCode(code int) *Response
- func (r *Response) ExpectSuccess() *Response
- func (r *Response) ExpectType(value string) *Response
- func (r *Response) GetBody(into *string) *Response
- func (r *Response) GetHeader(key string, into *string) *Response
- func (r *Response) GetJSON(into interface{}) *Response
- func (r *Response) MarshalJSON() ([]byte, error)
- func (r *Response) Next() *Next
- func (r *Response) Proxy(w io.Writer) *Response
- func (r *Response) UnmarshalJSON(b []byte) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Next ¶
type Next struct {
// contains filtered or unexported fields
}
Next is used to chain requests together
func (*Next) Delete ¶
Delete creates a new http "Delete" request for path (uri) and is used when chaining requests together
func (*Next) Get ¶
Get creates a new http "GET" request for path (uri) and is used when chaining requests together
func (*Next) New ¶
New creates a new request with given http method and path (uri) and is used when chaining requests together
type Request ¶
Request is the HTTP request to be sent
func (*Request) JSONBody ¶
JSONBody sets the given value as a JSON encoded string as the body of the request
func (*Request) MarshalJSON ¶
MarshalJSON implements `jsoniter.Marshaler` interface
func (*Request) MultipartBody ¶
func (r *Request) MultipartBody(form *questmultipart.Form) *Request
MultipartBody will set a multipart form as the body of the request
func (*Request) QueryParam ¶
QueryParam adds a query param to the url
func (*Request) UnmarshalJSON ¶
UnmarshalJSON implements `jsoniter.Unmarshaler` interface
func (*Request) WithContext ¶
WithContext sets up a context for this request
type Response ¶
Response is the HTTP response
func (*Response) Done ¶
Done will return the first error that occured durring the request's life-cycle
It is important to note that if any method errors, all subsequest methods will short circut and not be execuited
func (*Response) ExpectHeader ¶
ExpectHeader will error if given header is not set with given value
func (*Response) ExpectStatusCode ¶
ExpectStatusCode will error if StatusCode is not specified code
func (*Response) ExpectSuccess ¶
ExpectSuccess will error if StatusCode is not in 200 range
func (*Response) ExpectType ¶
ExpectType will error if header "Content-Type" is not specified value
func (*Response) MarshalJSON ¶
MarshalJSON implements `jsoniter.Marshaler` interface
func (*Response) Next ¶
Next allows a new request to be chained onto this request, assuming the first request did not fail
func (*Response) UnmarshalJSON ¶
UnmarshalJSON implements `jsoniter.Unmarshaler` interface