Documentation
¶
Index ¶
- func SetDefaultSetting(setting BhojpurHTTPSettings)
- func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
- type BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) Body(data interface{}) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) Bytes() ([]byte, error)
- func (b *BhojpurHTTPRequest) DoRequest() (resp *http.Response, err error)
- func (b *BhojpurHTTPRequest) GetRequest() *http.Request
- func (b *BhojpurHTTPRequest) Header(key, value string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) JSONBody(obj interface{}) (*BhojpurHTTPRequest, error)
- func (b *BhojpurHTTPRequest) Param(key, value string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) PostFile(formname, filename string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) Response() (*http.Response, error)
- func (b *BhojpurHTTPRequest) Retries(times int) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) RetryDelay(delay time.Duration) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetBasicAuth(username, password string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetCookie(cookie *http.Cookie) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetEnableCookie(enable bool) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetHost(host string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetProtocolVersion(vers string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetTLSClientConfig(config *tls.Config) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetTransport(transport http.RoundTripper) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) SetUserAgent(useragent string) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) Setting(setting BhojpurHTTPSettings) *BhojpurHTTPRequest
- func (b *BhojpurHTTPRequest) String() (string, error)
- func (b *BhojpurHTTPRequest) ToFile(filename string) error
- func (b *BhojpurHTTPRequest) ToJSON(v interface{}) error
- func (b *BhojpurHTTPRequest) ToXML(v interface{}) error
- func (b *BhojpurHTTPRequest) ToYAML(v interface{}) error
- func (b *BhojpurHTTPRequest) XMLBody(obj interface{}) (*BhojpurHTTPRequest, error)
- func (b *BhojpurHTTPRequest) YAMLBody(obj interface{}) (*BhojpurHTTPRequest, error)
- type BhojpurHTTPSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaultSetting ¶
func SetDefaultSetting(setting BhojpurHTTPSettings)
SetDefaultSetting Overwrite default settings
Types ¶
type BhojpurHTTPRequest ¶
type BhojpurHTTPRequest struct {
// contains filtered or unexported fields
}
BhojpurHTTPRequest provides more useful methods for requesting one url than http.Request.
func Delete ¶
func Delete(url string) *BhojpurHTTPRequest
Delete returns *BhojpurHttpRequest DELETE method.
func Get ¶
func Get(url string) *BhojpurHTTPRequest
Get returns *BhojpurHttpRequest with GET method.
func Head ¶
func Head(url string) *BhojpurHTTPRequest
Head returns *BhojpurHttpRequest with HEAD method.
func NewBhojpurRequest ¶
func NewBhojpurRequest(rawurl, method string) *BhojpurHTTPRequest
NewBhojpurRequest return *BhojpurHttpRequest with specific method
func Post ¶
func Post(url string) *BhojpurHTTPRequest
Post returns *BhojpurHttpRequest with POST method.
func Put ¶
func Put(url string) *BhojpurHTTPRequest
Put returns *BhojpurHttpRequest with PUT method.
func (*BhojpurHTTPRequest) Body ¶
func (b *BhojpurHTTPRequest) Body(data interface{}) *BhojpurHTTPRequest
Body adds request raw body. it supports string and []byte.
func (*BhojpurHTTPRequest) Bytes ¶
func (b *BhojpurHTTPRequest) Bytes() ([]byte, error)
Bytes returns the body []byte in response. it calls Response inner.
func (*BhojpurHTTPRequest) DoRequest ¶
func (b *BhojpurHTTPRequest) DoRequest() (resp *http.Response, err error)
DoRequest will do the client.Do
func (*BhojpurHTTPRequest) GetRequest ¶
func (b *BhojpurHTTPRequest) GetRequest() *http.Request
GetRequest return the request object
func (*BhojpurHTTPRequest) Header ¶
func (b *BhojpurHTTPRequest) Header(key, value string) *BhojpurHTTPRequest
Header add header item string in request.
func (*BhojpurHTTPRequest) JSONBody ¶
func (b *BhojpurHTTPRequest) JSONBody(obj interface{}) (*BhojpurHTTPRequest, error)
JSONBody adds request raw body encoding by JSON.
func (*BhojpurHTTPRequest) Param ¶
func (b *BhojpurHTTPRequest) Param(key, value string) *BhojpurHTTPRequest
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*BhojpurHTTPRequest) PostFile ¶
func (b *BhojpurHTTPRequest) PostFile(formname, filename string) *BhojpurHTTPRequest
PostFile add a post file to the request
func (*BhojpurHTTPRequest) Response ¶
func (b *BhojpurHTTPRequest) Response() (*http.Response, error)
Response executes request client gets response mannually.
func (*BhojpurHTTPRequest) Retries ¶
func (b *BhojpurHTTPRequest) Retries(times int) *BhojpurHTTPRequest
Retries sets Retries times. default is 0 means no retried. -1 means retried forever. others means retried times.
func (*BhojpurHTTPRequest) RetryDelay ¶
func (b *BhojpurHTTPRequest) RetryDelay(delay time.Duration) *BhojpurHTTPRequest
func (*BhojpurHTTPRequest) SetBasicAuth ¶
func (b *BhojpurHTTPRequest) SetBasicAuth(username, password string) *BhojpurHTTPRequest
SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.
func (*BhojpurHTTPRequest) SetCheckRedirect ¶
func (b *BhojpurHTTPRequest) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *BhojpurHTTPRequest
SetCheckRedirect specifies the policy for handling redirects.
If CheckRedirect is nil, the Client uses its default policy, which is to stop after 10 consecutive requests.
func (*BhojpurHTTPRequest) SetCookie ¶
func (b *BhojpurHTTPRequest) SetCookie(cookie *http.Cookie) *BhojpurHTTPRequest
SetCookie add cookie into request.
func (*BhojpurHTTPRequest) SetEnableCookie ¶
func (b *BhojpurHTTPRequest) SetEnableCookie(enable bool) *BhojpurHTTPRequest
SetEnableCookie sets enable/disable cookiejar
func (*BhojpurHTTPRequest) SetHost ¶
func (b *BhojpurHTTPRequest) SetHost(host string) *BhojpurHTTPRequest
SetHost set the request host
func (*BhojpurHTTPRequest) SetProtocolVersion ¶
func (b *BhojpurHTTPRequest) SetProtocolVersion(vers string) *BhojpurHTTPRequest
SetProtocolVersion Set the protocol version for incoming requests. Client requests always use HTTP/1.1.
func (*BhojpurHTTPRequest) SetProxy ¶
func (b *BhojpurHTTPRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *BhojpurHTTPRequest
SetProxy set the http proxy example:
func(req *http.Request) (*url.URL, error) {
u, _ := url.ParseRequestURI("http://127.0.0.1:8118")
return u, nil
}
func (*BhojpurHTTPRequest) SetTLSClientConfig ¶
func (b *BhojpurHTTPRequest) SetTLSClientConfig(config *tls.Config) *BhojpurHTTPRequest
SetTLSClientConfig sets tls connection configurations if visiting https url.
func (*BhojpurHTTPRequest) SetTimeout ¶
func (b *BhojpurHTTPRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *BhojpurHTTPRequest
SetTimeout sets connect time out and read-write time out for BhojpurRequest.
func (*BhojpurHTTPRequest) SetTransport ¶
func (b *BhojpurHTTPRequest) SetTransport(transport http.RoundTripper) *BhojpurHTTPRequest
SetTransport set the setting transport
func (*BhojpurHTTPRequest) SetUserAgent ¶
func (b *BhojpurHTTPRequest) SetUserAgent(useragent string) *BhojpurHTTPRequest
SetUserAgent sets User-Agent header field
func (*BhojpurHTTPRequest) Setting ¶
func (b *BhojpurHTTPRequest) Setting(setting BhojpurHTTPSettings) *BhojpurHTTPRequest
Setting Change request settings
func (*BhojpurHTTPRequest) String ¶
func (b *BhojpurHTTPRequest) String() (string, error)
String returns the body string in response. it calls Response inner.
func (*BhojpurHTTPRequest) ToFile ¶
func (b *BhojpurHTTPRequest) ToFile(filename string) error
ToFile saves the body data in response to one file. it calls Response inner.
func (*BhojpurHTTPRequest) ToJSON ¶
func (b *BhojpurHTTPRequest) ToJSON(v interface{}) error
ToJSON returns the map that marshals from the body bytes as json in response . it calls Response inner.
func (*BhojpurHTTPRequest) ToXML ¶
func (b *BhojpurHTTPRequest) ToXML(v interface{}) error
ToXML returns the map that marshals from the body bytes as xml in response . it calls Response inner.
func (*BhojpurHTTPRequest) ToYAML ¶
func (b *BhojpurHTTPRequest) ToYAML(v interface{}) error
ToYAML returns the map that marshals from the body bytes as yaml in response . it calls Response inner.
func (*BhojpurHTTPRequest) XMLBody ¶
func (b *BhojpurHTTPRequest) XMLBody(obj interface{}) (*BhojpurHTTPRequest, error)
XMLBody adds request raw body encoding by XML.
func (*BhojpurHTTPRequest) YAMLBody ¶
func (b *BhojpurHTTPRequest) YAMLBody(obj interface{}) (*BhojpurHTTPRequest, error)
YAMLBody adds request raw body encoding by YAML.
type BhojpurHTTPSettings ¶
type BhojpurHTTPSettings httplib.BhojpurHTTPSettings
BhojpurHTTPSettings is the http.Client setting