Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertTo(data interface{}) url.Values
- func Download(url string, filename string, perm os.FileMode) error
- func URLWithParams(rawUrl string, params map[string]interface{}) (u *url.URL)
- func URLWithPath(rawUrl string, path string, params map[string]interface{}) (u *url.URL)
- func Upload(url string, filename string, headerFunc HeaderFunc) ([]byte, error)
- func UploadV2(url string, form Form, headerFunc HeaderFunc) ([]byte, error)
- type FileForm
- type Form
- type HeaderFunc
- type Http
- func (hp *Http) Do(method string, url string, body io.Reader, headerFunc HeaderFunc, ...) ([]byte, error)
- func (hp *Http) DoBytes(method string, url string, buf []byte, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoForm(url string, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoFormWith(rawUrl, query string, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoFormWithValues(url string, values url.Values, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoMultiForm(url string, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoMultiFormWith(rawUrl, query string, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoMultiFormWithValues(url string, form url.Values, reqOpts ...RequestOption) ([]byte, error)
- func (hp *Http) DoString(method string, url string, buf []byte, reqOpts ...RequestOption) (string, error)
- func (hp *Http) DoWithHead(method string, url string, buf []byte, headerFunc HeaderFunc, ...) ([]byte, error)
- func (hp *Http) GetResponse() *Response
- func (hp *Http) LogEnabled() bool
- func (hp *Http) WithTimeout(duration time.Duration) *Http
- type ReadForm
- type RequestOption
- func Accept(ct string) RequestOption
- func Body(r io.Reader) RequestOption
- func ContentLength(l int64) RequestOption
- func ContentType(ct string) RequestOption
- func Context(ctx context.Context) RequestOption
- func FormBody(params map[string]interface{}) RequestOption
- func Header(headers map[string]string) RequestOption
- func JsonBody(body interface{}) RequestOption
- func Method(m string) RequestOption
- func Params(params map[string]interface{}) RequestOption
- func Path(path string) RequestOption
- func StringParams(params map[string]string) RequestOption
- func Trace(tracer *httptrace.ClientTrace) RequestOption
- func URL(u *url.URL) RequestOption
- func URLString(rawUrl string) RequestOption
- type Response
- type Url
Constants ¶
View Source
const ( KContentType = "Content-Type" KContentDisposition = "Content-Disposition" KContentLength = "content-length" )
View Source
const ( MimeJSON = "application/json" MimeHTML = "text/html" MimeXML = "application/xml" MimeXML2 = "text/xml" MimePlain = "text/plain" MimeForm = "application/x-www-form-urlencoded" MimeMultipartForm = "multipart/form-data" MimePROTOBUF = "application/x-protobuf" MimeMSGPACK = "application/x-msgpack" MimeMSGPACK2 = "application/msgpack" MimeYAML = "application/x-yaml" MimeJSONUtf8 = "application/json;charset=UTF-8" )
View Source
const URLTagName = "url"
Variables ¶
View Source
var ( HEAD = Method("HEAD") GET = Method("GET") POST = Method("POST") PUT = Method("PUT") DELETE = Method("DELETE") )
View Source
var EnableLog bool = true
View Source
var (
FormType = reflect.TypeOf((*Form)(nil)).Elem()
)
Functions ¶
func URLWithParams ¶ added in v1.2.10
func URLWithPath ¶ added in v1.2.10
Types ¶
type HeaderFunc ¶ added in v0.5.0
type Http ¶
type Http struct { DisableLog bool SeqNo string TimeOut time.Duration // contains filtered or unexported fields }
func (*Http) Do ¶
func (hp *Http) Do(method string, url string, body io.Reader, headerFunc HeaderFunc, reqOpts ...RequestOption) ([]byte, error)
func (*Http) DoForm ¶ added in v0.2.6
func (hp *Http) DoForm(url string, reqOpts ...RequestOption) ([]byte, error)
DoForm url http://api.xxx.com/ssddd?key=ddd&ddd=sfsf
func (*Http) DoFormWith ¶ added in v0.2.6
func (hp *Http) DoFormWith(rawUrl, query string, reqOpts ...RequestOption) ([]byte, error)
DoFormWith query ssddd=sdsfs&sfssfs=sfsssfs&sfsfsfs&
func (*Http) DoFormWithValues ¶ added in v0.2.6
func (*Http) DoMultiForm ¶ added in v0.2.6
func (hp *Http) DoMultiForm(url string, reqOpts ...RequestOption) ([]byte, error)
func (*Http) DoMultiFormWith ¶ added in v0.2.6
func (hp *Http) DoMultiFormWith(rawUrl, query string, reqOpts ...RequestOption) ([]byte, error)
func (*Http) DoMultiFormWithValues ¶ added in v0.2.6
func (*Http) DoWithHead ¶
func (hp *Http) DoWithHead(method string, url string, buf []byte, headerFunc HeaderFunc, reqOpts ...RequestOption) ([]byte, error)
func (*Http) GetResponse ¶ added in v1.2.10
func (*Http) LogEnabled ¶ added in v1.8.50
type RequestOption ¶ added in v1.2.10
func Accept ¶ added in v1.2.10
func Accept(ct string) RequestOption
func Body ¶ added in v1.2.10
func Body(r io.Reader) RequestOption
func ContentLength ¶ added in v1.2.10
func ContentLength(l int64) RequestOption
func ContentType ¶ added in v1.2.10
func ContentType(ct string) RequestOption
func Context ¶ added in v1.2.10
func Context(ctx context.Context) RequestOption
func FormBody ¶ added in v1.2.10
func FormBody(params map[string]interface{}) RequestOption
func Header ¶ added in v1.2.10
func Header(headers map[string]string) RequestOption
func JsonBody ¶ added in v1.2.10
func JsonBody(body interface{}) RequestOption
func Method ¶ added in v1.2.10
func Method(m string) RequestOption
func Params ¶ added in v1.2.10
func Params(params map[string]interface{}) RequestOption
func Path ¶ added in v1.2.10
func Path(path string) RequestOption
func StringParams ¶ added in v1.2.10
func StringParams(params map[string]string) RequestOption
func Trace ¶ added in v1.2.10
func Trace(tracer *httptrace.ClientTrace) RequestOption
func URL ¶ added in v1.2.10
func URL(u *url.URL) RequestOption
func URLString ¶ added in v1.2.10
func URLString(rawUrl string) RequestOption
type Response ¶ added in v1.2.10
type Response struct { StatusCode int // contains filtered or unexported fields }
Response 请求回应
func (*Response) GetContentDisposition ¶ added in v1.2.10
func (*Response) GetContentLength ¶ added in v1.2.10
func (*Response) GetContentType ¶ added in v1.2.10
type Url ¶ added in v1.1.36
func WithParams ¶ added in v1.2.10
func WithParams(data interface{}) Url
Click to show internal directories.
Click to hide internal directories.