mirror of
https://github.com/kataras/iris.git
synced 2026-01-05 11:17:03 +00:00
new /x/client sub-package
This commit is contained in:
35
x/client/option.go
Normal file
35
x/client/option.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package client
|
||||
|
||||
import "time"
|
||||
|
||||
// All the builtin client options should live here, for easy discovery.
|
||||
|
||||
type Option func(*Client)
|
||||
|
||||
// BaseURL registers the base URL of this client.
|
||||
// All of its methods will prepend this url.
|
||||
func BaseURL(uri string) Option {
|
||||
return func(c *Client) {
|
||||
c.BaseURL = uri
|
||||
}
|
||||
}
|
||||
|
||||
// Timeout specifies a time limit for requests made by this
|
||||
// Client. The timeout includes connection time, any
|
||||
// redirects, and reading the response body.
|
||||
// A Timeout of zero means no timeout.
|
||||
//
|
||||
// Defaults to 15 seconds.
|
||||
func Timeout(d time.Duration) Option {
|
||||
return func(c *Client) {
|
||||
c.HTTPClient.Timeout = d
|
||||
}
|
||||
}
|
||||
|
||||
// PersistentRequestOptions adds one or more persistent request options
|
||||
// that all requests made by this Client will respect.
|
||||
func PersistentRequestOptions(reqOpts ...RequestOption) Option {
|
||||
return func(c *Client) {
|
||||
c.PersistentRequestOptions = append(c.PersistentRequestOptions, reqOpts...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user