Documentation
¶
Index ¶
- Constants
- Variables
- func SetJSONMarshal(fn JSONMarshal)
- func SetJSONUnmarshal(fn JSONUnmarshal)
- type Adapter
- type Config
- type Instance
- func (ins *Instance) Delete(url string, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Get(url string, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Head(url string, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Mock(resp *Response) (done func())
- func (ins *Instance) MultiMock(multi map[string]*Response) (done func())
- func (ins *Instance) Options(url string, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Patch(url string, data interface{}, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Post(url string, data interface{}, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Put(url string, data interface{}, query ...url.Values) (resp *Response, err error)
- func (ins *Instance) Request(config *Config) (resp *Response, err error)
- type InstanceConfig
- type JSONMarshal
- type JSONUnmarshal
- type OnDone
- type OnError
- type RequestInterceptor
- type Response
- func Delete(url string) (resp *Response, err error)
- func Get(url string) (resp *Response, err error)
- func Head(url string) (resp *Response, err error)
- func Options(url string) (resp *Response, err error)
- func Patch(url string, data interface{}) (resp *Response, err error)
- func Post(url string, data interface{}) (resp *Response, err error)
- func Put(url string, data interface{}) (resp *Response, err error)
- func Request(config *Config) (resp *Response, err error)
- type ResponseInterceptor
- type TransformRequest
- type TransformResponse
Constants ¶
View Source
const (
// UserAgent client user agent
UserAgent = "go-axios/0.1.0"
)
Variables ¶
View Source
var ( // DefaultTransformResponse default transform response DefaultTransformResponse []TransformResponse // DefaultTransformRequest default transform request DefaultTransformRequest []TransformRequest )
Functions ¶
func SetJSONMarshal ¶ added in v0.0.6
func SetJSONMarshal(fn JSONMarshal)
SetJSONMarshal set json marshal function
func SetJSONUnmarshal ¶ added in v0.0.6
func SetJSONUnmarshal(fn JSONUnmarshal)
SetJSONUnmarshal set json unmarshal function
Types ¶
type Config ¶
type Config struct { Request *http.Request Response *Response // Route the request route Route string // URL the request url URL string // Method http request method, default is `get` Method string // BaseURL http request base url BaseURL string // TransformRequest transform requset body TransformRequest []TransformRequest // TransformResponse transofrm response body TransformResponse []TransformResponse // Headers custom headers for request Headers http.Header // Params params for request route Params map[string]string // Query query for requset Query url.Values // Body the request body Body interface{} // Concurrency current amount handling request of instance Concurrency uint32 // Timeout request timeout Timeout time.Duration // Context context Context context.Context // Client http client Client *http.Client // Adapter custom handling of requset Adapter Adapter // RequestInterceptors request interceptor list RequestInterceptors []RequestInterceptor // ResponseInterceptors response interceptor list ResponseInterceptors []ResponseInterceptor // OnError on error function OnError OnError // OnDone on done event OnDone OnDone HTTPTrace *HT.HTTPTrace // contains filtered or unexported fields }
Config http request config
type Instance ¶
type Instance struct { Config *InstanceConfig // contains filtered or unexported fields }
Instance instance of axios
func GetDefaultInstance ¶ added in v0.0.5
func GetDefaultInstance() *Instance
GetDefaultInstance get default instanc
func NewInstance ¶
func NewInstance(config *InstanceConfig) *Instance
NewInstance create a new instance
func (*Instance) Patch ¶
func (ins *Instance) Patch(url string, data interface{}, query ...url.Values) (resp *Response, err error)
Patch http patch request
func (*Instance) Post ¶
func (ins *Instance) Post(url string, data interface{}, query ...url.Values) (resp *Response, err error)
Post http post request
type InstanceConfig ¶
type InstanceConfig struct { // BaseURL http request base url BaseURL string // TransformRequest transform requset body TransformRequest []TransformRequest // TransformResponse transofrm response body TransformResponse []TransformResponse // Headers custom headers for request Headers http.Header // Timeout request timeout Timeout time.Duration // Client http client Client *http.Client // Adapter custom adapter Adapter Adapter // RequestInterceptors request interceptor list RequestInterceptors []RequestInterceptor // ResponseInterceptors response interceptor list ResponseInterceptors []ResponseInterceptor // EnableTrace enable http trace EnableTrace bool // OnError on error function OnError OnError // OnDone on done event OnDone OnDone }
InstanceConfig config of instance
type JSONMarshal ¶ added in v0.0.6
JSONMarshal json marshal function type
type JSONUnmarshal ¶ added in v0.0.6
JSONUnmarshal json unmarshal function type
type RequestInterceptor ¶
RequestInterceptor requset interceptor
type Response ¶
type Response struct { Data []byte Status int Headers http.Header Config *Config Request *http.Request }
Response http response
type ResponseInterceptor ¶
ResponseInterceptor response interceptor
type TransformRequest ¶
TransformRequest transform function for http request
Click to show internal directories.
Click to hide internal directories.