Documentation
¶
Index ¶
- Variables
- func DefaultUserAgent() string
- func SetBaseURL(url string)
- func SetTimeout(timeout time.Duration)
- func SetUserAgent(userAgent string)
- type Config
- type ConfigBody
- type ConfigHeaders
- type ConfigParams
- type ConfigQuery
- type DataSource
- type Fetch
- func (f *Fetch) Clone() *Fetch
- func (f *Fetch) Delete(url string, config ...*Config) *Fetch
- func (f *Fetch) Execute() (*Response, error)
- func (f *Fetch) Get(url string, config ...*Config) *Fetch
- func (f *Fetch) Head(url string, config ...*Config) *Fetch
- func (f *Fetch) Patch(url string, config ...*Config) *Fetch
- func (f *Fetch) Post(url string, config ...*Config) *Fetch
- func (f *Fetch) Put(url string, config ...*Config) *Fetch
- func (f *Fetch) Send() (*Response, error)
- func (f *Fetch) SetAuthorization(token string) *Fetch
- func (f *Fetch) SetBaseURL(url string) *Fetch
- func (f *Fetch) SetBasicAuth(username, password string) *Fetch
- func (f *Fetch) SetBearToken(token string) *Fetch
- func (f *Fetch) SetBody(body ConfigBody) *Fetch
- func (f *Fetch) SetConfig(configs ...*Config) *Fetch
- func (f *Fetch) SetHeader(key, value string) *Fetch
- func (f *Fetch) SetMethod(method string) *Fetch
- func (f *Fetch) SetParam(key, value string) *Fetch
- func (f *Fetch) SetQuery(key, value string) *Fetch
- func (f *Fetch) SetTimeout(timeout time.Duration) *Fetch
- func (f *Fetch) SetUrl(url string) *Fetch
- func (f *Fetch) SetUserAgent(userAgent string) *Fetch
- type Response
- func Delete(url string, config *Config) (*Response, error)
- func Get(url string, config ...interface{}) (*Response, error)
- func Head(url string, config ...interface{}) (*Response, error)
- func Patch(url string, config *Config) (*Response, error)
- func Post(url string, config *Config) (*Response, error)
- func Put(url string, config *Config) (*Response, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var BaseURL = ""
View Source
var DELETE = "DELETE"
View Source
var ErrCannotCopyFile = errors.New("cannot copy file")
View Source
var ErrCannotCreateFormFile = errors.New("cannot create form file")
View Source
var ErrCannotCreateRequest = errors.New("cannot create request")
View Source
var ErrCannotSendBodyWithGet = errors.New("cannot send body with GET method")
View Source
var ErrInvalidBodyMultipart = errors.New("invalid body multipart")
View Source
var ErrInvalidContentType = errors.New("invalid content type")
View Source
var ErrInvalidJSONBody = errors.New("error marshalling body")
View Source
var ErrInvalidMethod = errors.New("invalid method")
View Source
var ErrInvalidUrlFormEncodedBody = errors.New("invalid url form encoded body")
View Source
var ErrReadingResponse = errors.New("error reading response")
View Source
var ErrSendingRequest = errors.New("error sending request")
View Source
var ErrTooManyArguments = errors.New("too many arguments")
View Source
var ErrorInvalidBody = errors.New("invalid body")
View Source
var GET = "GET"
View Source
var HEAD = "HEAD"
View Source
var PATCH = "PATCH"
View Source
var POST = "POST"
View Source
var PUT = "PUT"
View Source
var Timeout = 60 * time.Second
View Source
var UserAgent = fmt.Sprintf("GoFetch/%s (github.com/go-zoox/fetch)", Version)
View Source
var Version = "1.0.1"
Functions ¶
func DefaultUserAgent ¶
func DefaultUserAgent() string
func SetBaseURL ¶
func SetBaseURL(url string)
func SetTimeout ¶
func SetUserAgent ¶
func SetUserAgent(userAgent string)
Types ¶
type Config ¶
type Config struct { Url string Method string Headers ConfigHeaders Query ConfigQuery Params ConfigParams Body ConfigBody // BaseURL string Timeout time.Duration }
func DefaultConfig ¶
func DefaultConfig() *Config
type ConfigBody ¶
type ConfigBody interface{}
type ConfigHeaders ¶
func (ConfigHeaders) Get ¶
func (h ConfigHeaders) Get(key string) string
type ConfigParams ¶
func (ConfigParams) Get ¶
func (h ConfigParams) Get(key string) string
type ConfigQuery ¶
func (ConfigQuery) Get ¶
func (h ConfigQuery) Get(key string) string
type DataSource ¶ added in v1.1.0
DataSource defines the interface for loading data from a data source.
type Fetch ¶
type Fetch struct { Errors []error // contains filtered or unexported fields }
func (*Fetch) SetAuthorization ¶ added in v1.1.1
func (*Fetch) SetBaseURL ¶
func (*Fetch) SetBasicAuth ¶ added in v1.1.1
func (*Fetch) SetBearToken ¶ added in v1.1.1
func (*Fetch) SetBody ¶
func (f *Fetch) SetBody(body ConfigBody) *Fetch
func (*Fetch) SetUserAgent ¶
type Response ¶
type Response struct { Status int Headers http.Header Body []byte // contains filtered or unexported fields }
func (*Response) UnmarshalJSON ¶ added in v1.1.4
func (*Response) UnmarshalYAML ¶ added in v1.1.4
Click to show internal directories.
Click to hide internal directories.