Documentation ¶
Index ¶
- Constants
- func Load(opts ...Option)
- func NewFormPayload(data map[string]interface{}) *formPayload
- func NewJSONPayload(data interface{}) *jsonPayload
- func NewKVParam(key string, value interface{}) *kvParam
- func NewMapParams(m map[string]interface{}) *mapParams
- func NewQueryParam(query string) *queryParam
- func NewWWWFormPayload(data map[string]interface{}) *wwwFormPayload
- type HiHTTP
- type Option
- type Options
- type Param
- type Payload
- type Request
- func (r *Request) Delete(ctx context.Context, urlStr string, data ...Param) ([]byte, error)
- func (r *Request) Get(ctx context.Context, urlStr string, data ...Param) ([]byte, error)
- func (r *Request) Patch(ctx context.Context, urlStr string, p Payload) ([]byte, error)
- func (r *Request) Post(ctx context.Context, urlStr string, p Payload) ([]byte, error)
- func (r *Request) Put(ctx context.Context, urlStr string, p Payload) ([]byte, error)
- func (r *Request) SetCookies(hc ...*http.Cookie) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetHeaders(args map[string]string) *Request
- type RetryErrorFunc
Constants ¶
View Source
const ( // MethodGet HTTP method GET = "GET" // MethodPost HTTP method POST = "POST" // MethodPut HTTP method PUT = "PUT" // MethodDelete HTTP method DELETE = "DELETE" // MethodDelete HTTP method PATCH = "PATCH" )
View Source
const ( SerializationType string = "Content-Type" SerializationTypeFormData string = "multipart/form-data" SerializationTypeJSON string = "application/json" SerializationTypeWWWFrom string = "application/x-www-form-urlencoded" SerializationTypePlainText string = "text/plain; charset=utf-8" )
Variables ¶
This section is empty.
Functions ¶
func NewFormPayload ¶
func NewFormPayload(data map[string]interface{}) *formPayload
NewFormPayload 会根据序列化类型,生成一个payload Content-Type = multipart/form-data
func NewJSONPayload ¶
func NewJSONPayload(data interface{}) *jsonPayload
NewJSONPayload 会根据序列化类型,生成一个payload Content-Type = application/json
func NewKVParam ¶
func NewKVParam(key string, value interface{}) *kvParam
func NewMapParams ¶
func NewMapParams(m map[string]interface{}) *mapParams
func NewQueryParam ¶
func NewQueryParam(query string) *queryParam
func NewWWWFormPayload ¶
func NewWWWFormPayload(data map[string]interface{}) *wwwFormPayload
NewWWWFormPayload 会根据序列化类型,生成一个payload Content-Type = application/x-www-form-urlencoded
Types ¶
type HiHTTP ¶
type HiHTTP interface { Get(ctx context.Context, urlStr string, data ...Param) ([]byte, error) Post(ctx context.Context, urlStr string, p Payload) ([]byte, error) Put(ctx context.Context, urlStr string, p Payload) ([]byte, error) Delete(ctx context.Context, urlStr string, data ...Param) ([]byte, error) Patch(ctx context.Context, urlStr string, p Payload) ([]byte, error) }
type Option ¶
type Option func(*Options)
func WithRetryCount ¶
func WithRetryError ¶
func WithRetryError(retryError RetryErrorFunc) Option
func WithRetryWait ¶
func WithTimeout ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) SetCookies ¶
SetCookies 设置cookie
Source Files ¶
Click to show internal directories.
Click to hide internal directories.