Documentation
¶
Index ¶
- Variables
- func GzipBody(body io.Reader) *bytes.Buffer
- func ReadBodyClose(response *http.Response) ([]byte, error)
- func ReadJsonClose(response *http.Response, v interface{}) error
- func ResetTransport()
- func SslSkipVerify()
- func TryUTF8ReadBodyClose(response *http.Response) ([]byte, error)
- type GHttpClient
- func Delete(url string, httpHeader header.GHttpHeader) *GHttpClient
- func Get(url string, httpHeader header.GHttpHeader) *GHttpClient
- func NewClient() *GHttpClient
- func Options(url string, httpHeader header.GHttpHeader) *GHttpClient
- func Patch(url string, body io.Reader, httpHeader header.GHttpHeader) *GHttpClient
- func Post(url string, body io.Reader, httpHeader header.GHttpHeader) *GHttpClient
- func PostForm(url string, data url.Values, httpHeader header.GHttpHeader) *GHttpClient
- func PostJson(url string, jsonBytes []byte, httpHeader header.GHttpHeader) *GHttpClient
- func Put(url string, body io.Reader, httpHeader header.GHttpHeader) *GHttpClient
- func PutJson(url string, jsonBytes []byte, httpHeader header.GHttpHeader) *GHttpClient
- func (g *GHttpClient) Body(body io.Reader) *GHttpClient
- func (g *GHttpClient) ContentType(contentType string) *GHttpClient
- func (g *GHttpClient) CookieJar(cookieJar http.CookieJar) *GHttpClient
- func (g *GHttpClient) Debug(debug bool) *GHttpClient
- func (g *GHttpClient) DebugOn() *GHttpClient
- func (g *GHttpClient) Delete() *GHttpClient
- func (g *GHttpClient) DeleteWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) Get() *GHttpClient
- func (g *GHttpClient) GetWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) Head() *GHttpClient
- func (g *GHttpClient) HeadWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) Header(headerKey, headerValue string) *GHttpClient
- func (g *GHttpClient) Headers(httpHeader header.GHttpHeader) *GHttpClient
- func (g *GHttpClient) LogDebug(flag string)
- func (g *GHttpClient) NoRedirect(noFollow bool) *GHttpClient
- func (g *GHttpClient) Options() *GHttpClient
- func (g *GHttpClient) OptionsWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) Patch() *GHttpClient
- func (g *GHttpClient) PatchWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) Post() *GHttpClient
- func (g *GHttpClient) PostWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) Proxy(proxyFunc func(req *http.Request) (*url.URL, error)) *GHttpClient
- func (g *GHttpClient) Put() *GHttpClient
- func (g *GHttpClient) PutWithContext(ctx context.Context) *GHttpClient
- func (g *GHttpClient) ReadBodyClose() ([]byte, error)
- func (g *GHttpClient) ReadJsonClose(v interface{}) error
- func (g *GHttpClient) Response() (*http.Response, error)
- func (g *GHttpClient) SslSkipVerify(skip bool) *GHttpClient
- func (g *GHttpClient) Timeout(timeout time.Duration) *GHttpClient
- func (g *GHttpClient) TryUTF8ReadBodyClose() ([]byte, error)
- func (g *GHttpClient) Url(url string) *GHttpClient
- func (g *GHttpClient) UserAgent(userAgent string) *GHttpClient
Constants ¶
This section is empty.
Variables ¶
var Debug bool
var Transport *http.Transport
Transport is the default transport for ghttpclient
Functions ¶
func ReadBodyClose ¶ added in v0.2.0
ReadBodyClose fetches the response Body, then close the Body supports gzip content-type
func ReadJsonClose ¶ added in v0.2.0
ReadJsonClose fetches the response Body and try to decode as a json, then close the Body
func SslSkipVerify ¶ added in v0.4.0
func SslSkipVerify()
SslSkipVerify sets whether or not skipping ssl verify
Types ¶
type GHttpClient ¶
type GHttpClient struct {
// contains filtered or unexported fields
}
GHttpClient is a Method chaining HTTP Client which is based on net/http.Client NewClient => set attributes of a request => do the request with an action(Get, Post...)
func Delete ¶
func Delete(url string, httpHeader header.GHttpHeader) *GHttpClient
Send a Request with DELETE method
func Get ¶
func Get(url string, httpHeader header.GHttpHeader) *GHttpClient
Send a Request with GET method
func Options ¶
func Options(url string, httpHeader header.GHttpHeader) *GHttpClient
Send a Request with OPTIONS method
func Patch ¶
func Patch(url string, body io.Reader, httpHeader header.GHttpHeader) *GHttpClient
Send a Request with PATCH method
func Post ¶
func Post(url string, body io.Reader, httpHeader header.GHttpHeader) *GHttpClient
Send a Request with POST method
func PostForm ¶
func PostForm(url string, data url.Values, httpHeader header.GHttpHeader) *GHttpClient
Send a Request as a form with POST method
func PostJson ¶
func PostJson(url string, jsonBytes []byte, httpHeader header.GHttpHeader) *GHttpClient
Send a Request as a json with POST Method
func Put ¶
func Put(url string, body io.Reader, httpHeader header.GHttpHeader) *GHttpClient
Send a Request with PUT method
func PutJson ¶
func PutJson(url string, jsonBytes []byte, httpHeader header.GHttpHeader) *GHttpClient
Send a Request as a json with PUT method
func (*GHttpClient) Body ¶
func (g *GHttpClient) Body(body io.Reader) *GHttpClient
Body sets the body of the request
func (*GHttpClient) ContentType ¶ added in v0.2.0
func (g *GHttpClient) ContentType(contentType string) *GHttpClient
ContentType sets the Content-Type header
func (*GHttpClient) CookieJar ¶ added in v0.3.1
func (g *GHttpClient) CookieJar(cookieJar http.CookieJar) *GHttpClient
CookieJar sets the cookie jar of the request
func (*GHttpClient) Debug ¶ added in v0.3.0
func (g *GHttpClient) Debug(debug bool) *GHttpClient
Debug sets debug to the value of param
func (*GHttpClient) DebugOn ¶ added in v0.3.0
func (g *GHttpClient) DebugOn() *GHttpClient
DebugOn sets debug to true
func (*GHttpClient) Delete ¶
func (g *GHttpClient) Delete() *GHttpClient
Delete sends the Request with DELETE method
func (*GHttpClient) DeleteWithContext ¶ added in v0.4.0
func (g *GHttpClient) DeleteWithContext(ctx context.Context) *GHttpClient
DeleteWithContext
func (*GHttpClient) Get ¶
func (g *GHttpClient) Get() *GHttpClient
Get sends the Request with GET method
func (*GHttpClient) GetWithContext ¶ added in v0.4.0
func (g *GHttpClient) GetWithContext(ctx context.Context) *GHttpClient
GetWithContext
func (*GHttpClient) Head ¶
func (g *GHttpClient) Head() *GHttpClient
Head sends the Request with HEAD method
func (*GHttpClient) HeadWithContext ¶ added in v0.4.0
func (g *GHttpClient) HeadWithContext(ctx context.Context) *GHttpClient
HeadWithContext
func (*GHttpClient) Header ¶
func (g *GHttpClient) Header(headerKey, headerValue string) *GHttpClient
Header sets a header
func (*GHttpClient) Headers ¶
func (g *GHttpClient) Headers(httpHeader header.GHttpHeader) *GHttpClient
Headers sets a group of headers
func (*GHttpClient) LogDebug ¶ added in v0.3.0
func (g *GHttpClient) LogDebug(flag string)
func (*GHttpClient) NoRedirect ¶ added in v0.3.3
func (g *GHttpClient) NoRedirect(noFollow bool) *GHttpClient
NoRedirect sets whether or not to stop following redirects
func (*GHttpClient) Options ¶
func (g *GHttpClient) Options() *GHttpClient
Options sends the Request with OPTIONS method
func (*GHttpClient) OptionsWithContext ¶ added in v0.4.0
func (g *GHttpClient) OptionsWithContext(ctx context.Context) *GHttpClient
OptionsWithContext
func (*GHttpClient) Patch ¶
func (g *GHttpClient) Patch() *GHttpClient
Patch sends the Request with PATCH method
func (*GHttpClient) PatchWithContext ¶ added in v0.4.0
func (g *GHttpClient) PatchWithContext(ctx context.Context) *GHttpClient
Patch sends the Request with PATCH method
func (*GHttpClient) Post ¶
func (g *GHttpClient) Post() *GHttpClient
Post sends the Request with POST method
func (*GHttpClient) PostWithContext ¶ added in v0.4.0
func (g *GHttpClient) PostWithContext(ctx context.Context) *GHttpClient
PostWithContext
func (*GHttpClient) Proxy ¶ added in v0.4.3
func (g *GHttpClient) Proxy(proxyFunc func(req *http.Request) (*url.URL, error)) *GHttpClient
Proxy sets a proxyFunc
func (*GHttpClient) Put ¶
func (g *GHttpClient) Put() *GHttpClient
Put sends the Request with PUT method
func (*GHttpClient) PutWithContext ¶ added in v0.4.0
func (g *GHttpClient) PutWithContext(ctx context.Context) *GHttpClient
PutWithContext
func (*GHttpClient) ReadBodyClose ¶ added in v0.3.0
func (g *GHttpClient) ReadBodyClose() ([]byte, error)
ReadBodyClose fetches the response Body, then close the Body supports gzip content-type
func (*GHttpClient) ReadJsonClose ¶ added in v0.3.0
func (g *GHttpClient) ReadJsonClose(v interface{}) error
ReadJsonClose fetches the response Body and try to decode as a json, then close the Body
func (*GHttpClient) Response ¶ added in v0.3.0
func (g *GHttpClient) Response() (*http.Response, error)
Response returns http.Response and error
func (*GHttpClient) SslSkipVerify ¶
func (g *GHttpClient) SslSkipVerify(skip bool) *GHttpClient
SslSkipVerify sets whether or not skipping ssl verify Deprecated: use package SslSkipVerify instead
func (*GHttpClient) Timeout ¶
func (g *GHttpClient) Timeout(timeout time.Duration) *GHttpClient
Timeout sets a timeout to the http client
func (*GHttpClient) TryUTF8ReadBodyClose ¶ added in v0.3.0
func (g *GHttpClient) TryUTF8ReadBodyClose() ([]byte, error)
TryUTF8ReadBodyClose tries to transfer the body bytes to utf-8 bytes when the body bytes is not in utf-8 encoding
func (*GHttpClient) Url ¶
func (g *GHttpClient) Url(url string) *GHttpClient
Url sets the url to request to
func (*GHttpClient) UserAgent ¶ added in v0.2.0
func (g *GHttpClient) UserAgent(userAgent string) *GHttpClient
UserAgent sets the User-Agent header