Documentation ¶
Index ¶
- type AsyncResponse
- type MultipartParam
- type Option
- type OptionFunc
- type Request
- func (req *Request) AsyncDelete(url string, ch chan<- *AsyncResponse)
- func (req *Request) AsyncGet(url string, ch chan<- *AsyncResponse)
- func (req *Request) AsyncPatch(url string, ch chan<- *AsyncResponse)
- func (req *Request) AsyncPost(url string, ch chan<- *AsyncResponse)
- func (req *Request) AsyncPut(url string, ch chan<- *AsyncResponse)
- func (req *Request) BasicAuth(username, password string) *Request
- func (req *Request) Body(formValues []byte) *Request
- func (req *Request) CustomBody(formValues []byte, contentType string) *Request
- func (req *Request) Delete(url string) (*Response, error)
- func (req *Request) FormData(formValues map[string]string) *Request
- func (req *Request) Get(url string) (*Response, error)
- func (req *Request) Head(url string) (*Response, error)
- func (req *Request) Headers(headerVals map[string]string) *Request
- func (req *Request) JSON(jsonBody map[string]interface{}) *Request
- func (req *Request) MultipartFormData(formData map[string]string) *Request
- func (req *Request) Options(url string) (*Response, error)
- func (req *Request) Patch(url string) (*Response, error)
- func (req *Request) Post(url string) (*Response, error)
- func (req *Request) Put(url string) (*Response, error)
- func (req *Request) Query(formValues map[string]string) *Request
- func (req *Request) Text(formValues string) *Request
- func (req *Request) Upload(name, file string) *Request
- func (req *Request) UploadFromReader(param MultipartParam) *Request
- func (req *Request) Uploads(files map[string]string) *Request
- func (req *Request) UploadsFromReader(params []MultipartParam) *Request
- type Response
- func (res *Response) GetBody() io.ReadCloser
- func (res *Response) GetBodyAsByte() ([]byte, error)
- func (res *Response) GetBodyAsJSONRawMessage() (json.RawMessage, error)
- func (res *Response) GetBodyAsString() (string, error)
- func (res *Response) GetResp() *http.Response
- func (res *Response) GetStatusCode() int
- func (res *Response) Protocol() string
- func (res *Response) URL() (*url.URL, error)
- func (res *Response) UnmarshalBody(v interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncResponse ¶
AsyncResponse is a response struct for asynchronous request
type MultipartParam ¶
MultipartParam is a multipart param type
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an interface of request option
type OptionFunc ¶
type OptionFunc func(*Request)
OptionFunc is an implementation of option interface
func SetClient ¶
func SetClient(c *http.Client) OptionFunc
SetClient option sets client c for request
func SetCookieJar ¶
func SetCookieJar(c http.CookieJar) OptionFunc
SetCookieJar option sets cookie c for request
func SetTimeout ¶
func SetTimeout(t time.Duration) OptionFunc
SetTimeout option sets timeout t for request
func SetTransport ¶
func SetTransport(t *http.Transport) OptionFunc
SetTransport option sets Transport t for request
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a request type
func (*Request) AsyncDelete ¶
func (req *Request) AsyncDelete(url string, ch chan<- *AsyncResponse)
AsyncDelete is a asynchronous delete http request
func (*Request) AsyncGet ¶
func (req *Request) AsyncGet(url string, ch chan<- *AsyncResponse)
AsyncGet is a asynchronous get http request
func (*Request) AsyncPatch ¶
func (req *Request) AsyncPatch(url string, ch chan<- *AsyncResponse)
AsyncPatch is a asynchronous patch http request
func (*Request) AsyncPost ¶
func (req *Request) AsyncPost(url string, ch chan<- *AsyncResponse)
AsyncPost is a asynchronous post http request
func (*Request) AsyncPut ¶
func (req *Request) AsyncPut(url string, ch chan<- *AsyncResponse)
AsyncPut is a asynchronous put http request
func (*Request) CustomBody ¶
func (*Request) MultipartFormData ¶
MultipartFormData add form data in multipart request
func (*Request) UploadFromReader ¶
func (req *Request) UploadFromReader(param MultipartParam) *Request
UploadFromReader upload a single file
func (*Request) UploadsFromReader ¶
func (req *Request) UploadsFromReader(params []MultipartParam) *Request
UploadsFromReader upload multiple files
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is a http response struct
func (*Response) GetBody ¶
func (res *Response) GetBody() io.ReadCloser
GetBody returns response body It is the caller's responsibility to close Body
func (*Response) GetBodyAsByte ¶
GetBodyAsByte returns response body as byte
func (*Response) GetBodyAsJSONRawMessage ¶
func (res *Response) GetBodyAsJSONRawMessage() (json.RawMessage, error)
GetBodyAsJSONRawMessage returns response body as json.RawMessage
func (*Response) GetBodyAsString ¶
GetBodyAsString returns response body as string
func (*Response) GetStatusCode ¶
GetStatusCode returns http status code if Response is not returned from a Request the status code will be 0
func (*Response) UnmarshalBody ¶
UnmarshalBody unmarshal response body