Documentation
¶
Index ¶
- Constants
- Variables
- func AsyncGet(rawUrl string, ch chan<- *AsyncResponse)
- func Middleware(t http.RoundTripper, mfs ...MiddlewareFunc) http.RoundTripper
- type AsyncResponse
- type Client
- type Handle
- type HttpClient
- type MiddlewareFunc
- type Request
- func (r *Request) AddCookie(c *http.Cookie) *Request
- func (r *Request) AddHeader(key, value string) *Request
- func (r *Request) AddHeaders(m map[string]string) *Request
- func (r *Request) BasicAuth(username, password string) *Request
- func (r *Request) Do() (resp *Response, err error)
- func (r *Request) SetFile(field, filename string) *Request
- func (r *Request) SetForm(m map[string]string) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetHeaders(m map[string]string) *Request
- func (r *Request) SetJSON(v string) *Request
- func (r *Request) SetQueries(m map[string]string) *Request
- func (r *Request) SetQuery(key, value string) *Request
- func (r *Request) SetText(v string) *Request
- func (r *Request) SetTimeout(t time.Duration) *Request
- func (r *Request) SetUA(ua string) *Request
- type Response
- type TransportFunc
Constants ¶
View Source
const ( GET = "GET" POST = "POST" PUT = "PUT" HEAD = "HEAD" PATCH = "PATCH" DELETE = "DELETE" OPTIONS = "OPTIONS" )
HTTP methods support
View Source
const ( JSON = "application/json;charset=UTF-8" TEXT = "text/plain;charset=UTF-8" FORM_DATA = "multipart/form-data;charset=UTF-8" FORM_URLENCODED = "application/x-www-form-urlencoded;charset=UTF-8" )
content type support
Variables ¶
View Source
var DefaultClient = NewClient()
Functions ¶
func AsyncGet ¶
func AsyncGet(rawUrl string, ch chan<- *AsyncResponse)
func Middleware ¶
func Middleware(t http.RoundTripper, mfs ...MiddlewareFunc) http.RoundTripper
Types ¶
type AsyncResponse ¶
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(mfs ...MiddlewareFunc) *HttpClient
func (*HttpClient) Get ¶
func (h *HttpClient) Get(rawUrl string) *Request
func (*HttpClient) NewRequest ¶
func (h *HttpClient) NewRequest(method, rawUrl string) *Request
func (*HttpClient) Post ¶
func (h *HttpClient) Post(rawUrl string) *Request
type MiddlewareFunc ¶
type MiddlewareFunc func(http.RoundTripper) http.RoundTripper
func WithBasicAuth ¶
func WithBasicAuth(username, password string) MiddlewareFunc
func WithLogger ¶
func WithLogger(l *log.Logger) MiddlewareFunc
type Request ¶
func (*Request) AddHeaders ¶
AddHeaders add headers from a map for the request
func (*Request) SetHeaders ¶
SetHeaders set headers from a map for the request
func (*Request) SetQueries ¶
SetQueries set URL query params for the request
func (*Request) SetTimeout ¶
SetTimeout set the request timeout
type Response ¶
func (*Response) GetStatusCode ¶
GetStatusCode get HTTP status code
Click to show internal directories.
Click to hide internal directories.