Documentation ¶
Overview ¶
Package request HTTP request
Index ¶
- type DefaultRequest
- func (srv *DefaultRequest) Get(ctx context.Context, url string) ([]byte, error)
- func (srv *DefaultRequest) Post(ctx context.Context, url string, data []byte) ([]byte, error)
- func (srv *DefaultRequest) PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)
- func (srv *DefaultRequest) PostJSON(ctx context.Context, url string, data any) ([]byte, error)
- func (srv *DefaultRequest) PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error)
- func (srv *DefaultRequest) PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) (resp []byte, err error)
- func (srv *DefaultRequest) PostXML(ctx context.Context, url string, data any) ([]byte, error)
- func (srv *DefaultRequest) PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error)
- type MultipartFormField
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultRequest ¶
type DefaultRequest struct {
AccessTokenKey string
}
DefaultRequest 默认请求
func NewDefaultRequest ¶
func NewDefaultRequest(accessTokenKey string) *DefaultRequest
NewDefaultRequest 实例化
func (*DefaultRequest) PostFile ¶
func (srv *DefaultRequest) PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)
PostFile HTTP post file request
func (*DefaultRequest) PostJSONWithRespContentType ¶
func (srv *DefaultRequest) PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error)
PostJSONWithRespContentType HTTP post JSON request with the response content type
func (*DefaultRequest) PostMultipartForm ¶
func (srv *DefaultRequest) PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) (resp []byte, err error)
PostMultipartForm HTTP post multipart form request
func (*DefaultRequest) PostXML ¶ added in v0.0.3
PostXML perform the HTTP/POST request with XML body
func (*DefaultRequest) PostXMLWithTLS ¶ added in v0.0.4
func (srv *DefaultRequest) PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error)
PostXMLWithTLS perform the HTTP/POST request with XML body and TLS
type MultipartFormField ¶
type MultipartFormField struct { IsFile bool `json:"isFile"` Value []byte `json:"value"` FieldName string `json:"fieldName"` FileName string `json:"fileName"` }
MultipartFormField multipart form field
type Request ¶
type Request interface { Get(ctx context.Context, url string) ([]byte, error) Post(ctx context.Context, url string, data []byte) ([]byte, error) PostJSON(ctx context.Context, url string, data any) ([]byte, error) PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error) PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error) PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) ([]byte, error) PostXML(ctx context.Context, url string, data any) ([]byte, error) PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error) }
Request HTTP request interface
Click to show internal directories.
Click to hide internal directories.