Documentation
¶
Index ¶
- Variables
- func NewUploadRateReader(reader io.Reader, rate uint64) io.Reader
- func SetDefaultFileSplitSize(chunkSize int64)
- type HTTPAccept
- type HTTPClient
- func DELETE(attrs ...HTTPClientAttr) (HTTPClient, error)
- func GET(attrs ...HTTPClientAttr) (HTTPClient, error)
- func HEAD(attrs ...HTTPClientAttr) (HTTPClient, error)
- func New(attrs ...HTTPClientAttr) (HTTPClient, error)
- func OPTIONS(attrs ...HTTPClientAttr) (HTTPClient, error)
- func PATCH(attrs ...HTTPClientAttr) (HTTPClient, error)
- func POST(attrs ...HTTPClientAttr) (HTTPClient, error)
- func PUT(attrs ...HTTPClientAttr) (HTTPClient, error)
- func TRACE(attrs ...HTTPClientAttr) (HTTPClient, error)
- type HTTPClientAttr
- func Accept(accept HTTPAccept) HTTPClientAttr
- func AppendAccept(accept HTTPAccept) HTTPClientAttr
- func AppendContentType(ct HTTPContentType) HTTPClientAttr
- func AppendHeader(key string, value any) HTTPClientAttr
- func AppendHeaders(headers map[string][]any) HTTPClientAttr
- func Authorization(username, password, title string) HTTPClientAttr
- func AutoCopy(autoCopy bool) HTTPClientAttr
- func Bytes(body []byte) HTTPClientAttr
- func CSS(body string) HTTPClientAttr
- func Cert(cert []byte) HTTPClientAttr
- func Compressor(compressor compressions.Compressor) HTTPClientAttr
- func ContentType(ct HTTPContentType) HTTPClientAttr
- func Encrypt(symmetricEncryptor secrets.Symmetric) HTTPClientAttr
- func File(filename string, goroutineCount uint64) HTTPClientAttr
- func Form(body map[string]any) HTTPClientAttr
- func FormData(fields, files map[string]string) HTTPClientAttr
- func HTML(body string) HTTPClientAttr
- func Header(key string, value any) HTTPClientAttr
- func Headers(headers map[string][]any) HTTPClientAttr
- func JSON(body any) HTTPClientAttr
- func Javascript(body string) HTTPClientAttr
- func Method(method string) HTTPClientAttr
- func Plain(body string) HTTPClientAttr
- func Queries(queries map[string]any) HTTPClientAttr
- func QueriesNotEmpty(queries map[string]any) HTTPClientAttr
- func Query(key string, value any) HTTPClientAttr
- func RateLimit(rate uint64) HTTPClientAttr
- func ReadCloser(body io.ReadCloser) HTTPClientAttr
- func Timeout(timeout time.Duration) HTTPClientAttr
- func Transport(transport *http.Transport) HTTPClientAttr
- func TransportDefault() HTTPClientAttr
- func URL(urls ...any) HTTPClientAttr
- func XML(body any) HTTPClientAttr
- type HTTPClientImpl
- func (my *HTTPClientImpl) Error() error
- func (my *HTTPClientImpl) GetBody() []byte
- func (my *HTTPClientImpl) GetCert() []byte
- func (my *HTTPClientImpl) GetClient() *http.Client
- func (my *HTTPClientImpl) GetHeaders() map[string][]any
- func (my *HTTPClientImpl) GetMethod() string
- func (my *HTTPClientImpl) GetQueries() map[string]any
- func (my *HTTPClientImpl) GetRawRequest() *http.Request
- func (my *HTTPClientImpl) GetRawResponse() *http.Response
- func (my *HTTPClientImpl) GetStatus() string
- func (my *HTTPClientImpl) GetStatusCode() int
- func (my *HTTPClientImpl) GetTimeout() time.Duration
- func (my *HTTPClientImpl) GetTransport() *http.Transport
- func (my *HTTPClientImpl) GetURL() string
- func (my *HTTPClientImpl) OK() error
- func (my *HTTPClientImpl) Send() HTTPClient
- func (my *HTTPClientImpl) SendWithRetry(count uint, interval time.Duration, ...) (HTTPClient, []error)
- func (my *HTTPClientImpl) SetAttrs(attrs ...HTTPClientAttr) (HTTPClient, error)
- func (my *HTTPClientImpl) ToBytes() []byte
- func (my *HTTPClientImpl) ToJSON(target any, keys ...any) HTTPClient
- func (my *HTTPClientImpl) ToWriter(writer http.ResponseWriter) HTTPClient
- func (my *HTTPClientImpl) ToXML(target any) HTTPClient
- type HTTPContentType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ContentTypeJSON HTTPContentType = "application/json" ContentTypeXML HTTPContentType = "application/xml" ContentTypeXWWWFormURLEncoded HTTPContentType = "application/x-www-form-urlencoded" ContentTypeFormData HTTPContentType = "form-data" ContentTypePlain HTTPContentType = "text/plain" ContentTypeHTML HTTPContentType = "text/html" ContentTypeCSS HTTPContentType = "text/css" ContentTypeJavascript HTTPContentType = "text/javascript" ContentTypeSteam HTTPContentType = "application/octet-stream" HTTPContentTypes = map[HTTPContentType]string{ ContentTypeJSON: "application/json", ContentTypeXML: "application/xml", ContentTypeXWWWFormURLEncoded: "application/x-www-form-urlencoded", ContentTypeFormData: "form-data", ContentTypePlain: "text/plain", ContentTypeHTML: "text/html", ContentTypeCSS: "text/css", ContentTypeJavascript: "text/javascript", ContentTypeSteam: "application/octet-stream", } AcceptJSON HTTPAccept = "application/json" AcceptXML HTTPAccept = "application/xml" AcceptPlain HTTPAccept = "text/plain" AcceptHTML HTTPAccept = "text/html" AcceptCSS HTTPAccept = "text/css" AcceptJavascript HTTPAccept = "text/javascript" AcceptSteam HTTPAccept = "application/octet-stream" AcceptAny HTTPAccept = "*/*" HTTPAccepts = map[HTTPAccept]string{ AcceptJSON: "application/json", AcceptXML: "application/xml", AcceptPlain: "text/plain", AcceptHTML: "text/html", AcceptCSS: "text/css", AcceptJavascript: "text/javascript", AcceptSteam: "application/octet-stream", AcceptAny: "*/*", } )
Functions ¶
func SetDefaultFileSplitSize ¶
func SetDefaultFileSplitSize(chunkSize int64)
SetDefaultFileSplitSize 设置默认文件切块大小
Types ¶
type HTTPAccept ¶
type HTTPAccept string
type HTTPClient ¶
type HTTPClient interface {
SetAttrs(attrs ...HTTPClientAttr) (HTTPClient, error)
GetURL() string
GetQueries() map[string]any
GetMethod() string
GetHeaders() map[string][]any
GetBody() []byte
GetTimeout() time.Duration
GetTransport() *http.Transport
GetCert() []byte
GetRawRequest() *http.Request
GetRawResponse() *http.Response
GetClient() *http.Client
OK() error
SendWithRetry(count uint, interval time.Duration, condition func(statusCode int, err error) bool) (HTTPClient, []error)
Send() HTTPClient
ToJSON(target any, keys ...any) HTTPClient
ToXML(target any) HTTPClient
ToBytes() []byte
ToWriter(writer http.ResponseWriter) HTTPClient
Error() error
GetStatusCode() int
GetStatus() string
// contains filtered or unexported methods
}
func DELETE ¶
func DELETE(attrs ...HTTPClientAttr) (HTTPClient, error)
func GET ¶
func GET(attrs ...HTTPClientAttr) (HTTPClient, error)
func HEAD ¶
func HEAD(attrs ...HTTPClientAttr) (HTTPClient, error)
func New ¶
func New(attrs ...HTTPClientAttr) (HTTPClient, error)
func OPTIONS ¶
func OPTIONS(attrs ...HTTPClientAttr) (HTTPClient, error)
func PATCH ¶
func PATCH(attrs ...HTTPClientAttr) (HTTPClient, error)
func POST ¶
func POST(attrs ...HTTPClientAttr) (HTTPClient, error)
func PUT ¶
func PUT(attrs ...HTTPClientAttr) (HTTPClient, error)
func TRACE ¶
func TRACE(attrs ...HTTPClientAttr) (HTTPClient, error)
type HTTPClientAttr ¶
type HTTPClientAttr func(hc HTTPClient) (err error)
func Accept ¶
func Accept(accept HTTPAccept) HTTPClientAttr
func AppendAccept ¶
func AppendAccept(accept HTTPAccept) HTTPClientAttr
func AppendContentType ¶
func AppendContentType(ct HTTPContentType) HTTPClientAttr
func AppendHeader ¶
func AppendHeader(key string, value any) HTTPClientAttr
func AppendHeaders ¶
func AppendHeaders(headers map[string][]any) HTTPClientAttr
func Authorization ¶
func Authorization(username, password, title string) HTTPClientAttr
func AutoCopy ¶
func AutoCopy(autoCopy bool) HTTPClientAttr
func Bytes ¶
func Bytes(body []byte) HTTPClientAttr
func CSS ¶
func CSS(body string) HTTPClientAttr
func Cert ¶
func Cert(cert []byte) HTTPClientAttr
func Compressor ¶
func Compressor(compressor compressions.Compressor) HTTPClientAttr
func ContentType ¶
func ContentType(ct HTTPContentType) HTTPClientAttr
func Encrypt ¶
func Encrypt(symmetricEncryptor secrets.Symmetric) HTTPClientAttr
func File ¶
func File(filename string, goroutineCount uint64) HTTPClientAttr
func Form ¶
func Form(body map[string]any) HTTPClientAttr
func FormData ¶
func FormData(fields, files map[string]string) HTTPClientAttr
func HTML ¶
func HTML(body string) HTTPClientAttr
func Header ¶
func Header(key string, value any) HTTPClientAttr
func Headers ¶
func Headers(headers map[string][]any) HTTPClientAttr
func JSON ¶
func JSON(body any) HTTPClientAttr
func Javascript ¶
func Javascript(body string) HTTPClientAttr
func Method ¶
func Method(method string) HTTPClientAttr
func Plain ¶
func Plain(body string) HTTPClientAttr
func Queries ¶
func Queries(queries map[string]any) HTTPClientAttr
func QueriesNotEmpty ¶
func QueriesNotEmpty(queries map[string]any) HTTPClientAttr
func Query ¶
func Query(key string, value any) HTTPClientAttr
func RateLimit ¶
func RateLimit(rate uint64) HTTPClientAttr
func ReadCloser ¶
func ReadCloser(body io.ReadCloser) HTTPClientAttr
func Timeout ¶
func Timeout(timeout time.Duration) HTTPClientAttr
func Transport ¶
func Transport(transport *http.Transport) HTTPClientAttr
func TransportDefault ¶
func TransportDefault() HTTPClientAttr
func URL ¶
func URL(urls ...any) HTTPClientAttr
func XML ¶
func XML(body any) HTTPClientAttr
type HTTPClientImpl ¶
type HTTPClientImpl struct {
// contains filtered or unexported fields
}
func (*HTTPClientImpl) Error ¶
func (my *HTTPClientImpl) Error() error
func (*HTTPClientImpl) GetBody ¶
func (my *HTTPClientImpl) GetBody() []byte
func (*HTTPClientImpl) GetCert ¶
func (my *HTTPClientImpl) GetCert() []byte
func (*HTTPClientImpl) GetClient ¶
func (my *HTTPClientImpl) GetClient() *http.Client
func (*HTTPClientImpl) GetHeaders ¶
func (my *HTTPClientImpl) GetHeaders() map[string][]any
func (*HTTPClientImpl) GetMethod ¶
func (my *HTTPClientImpl) GetMethod() string
func (*HTTPClientImpl) GetQueries ¶
func (my *HTTPClientImpl) GetQueries() map[string]any
func (*HTTPClientImpl) GetRawRequest ¶
func (my *HTTPClientImpl) GetRawRequest() *http.Request
func (*HTTPClientImpl) GetRawResponse ¶
func (my *HTTPClientImpl) GetRawResponse() *http.Response
func (*HTTPClientImpl) GetStatus ¶
func (my *HTTPClientImpl) GetStatus() string
func (*HTTPClientImpl) GetStatusCode ¶
func (my *HTTPClientImpl) GetStatusCode() int
func (*HTTPClientImpl) GetTimeout ¶
func (my *HTTPClientImpl) GetTimeout() time.Duration
func (*HTTPClientImpl) GetTransport ¶
func (my *HTTPClientImpl) GetTransport() *http.Transport
func (*HTTPClientImpl) GetURL ¶
func (my *HTTPClientImpl) GetURL() string
func (*HTTPClientImpl) Send ¶
func (my *HTTPClientImpl) Send() HTTPClient
func (*HTTPClientImpl) SendWithRetry ¶
func (my *HTTPClientImpl) SendWithRetry(count uint, interval time.Duration, condition func(statusCode int, err error) bool) (HTTPClient, []error)
func (*HTTPClientImpl) SetAttrs ¶
func (my *HTTPClientImpl) SetAttrs(attrs ...HTTPClientAttr) (HTTPClient, error)
func (*HTTPClientImpl) ToBytes ¶
func (my *HTTPClientImpl) ToBytes() []byte
func (*HTTPClientImpl) ToJSON ¶
func (my *HTTPClientImpl) ToJSON(target any, keys ...any) HTTPClient
func (*HTTPClientImpl) ToWriter ¶
func (my *HTTPClientImpl) ToWriter(writer http.ResponseWriter) HTTPClient
func (*HTTPClientImpl) ToXML ¶
func (my *HTTPClientImpl) ToXML(target any) HTTPClient
type HTTPContentType ¶
type HTTPContentType = string
Click to show internal directories.
Click to hide internal directories.