Documentation
¶
Index ¶
- Constants
- Variables
- type Accept
- type AttrAccept
- type AttrAuthorization
- type AttrAutoCopy
- type AttrBody
- func Bytes(body []byte) *AttrBody
- func CSS(body string) *AttrBody
- func File(filename string) *AttrBody
- func Form(body map[string]string) *AttrBody
- func FormData(fields, files map[string]string) *AttrBody
- func HTML(body string) *AttrBody
- func JSON(body any) *AttrBody
- func Javascript(body string) *AttrBody
- func Plain(body string) *AttrBody
- func Reader(body io.ReadCloser) *AttrBody
- func XML(body any) *AttrBody
- type AttrCert
- type AttrContentType
- type AttrHeader
- type AttrMethod
- type AttrQueries
- type AttrTimeout
- type AttrTransport
- type AttrURL
- type ContentType
- type HTTPClient
- func Acquire() *HTTPClient
- func DELETE(attrs ...HTTPClientAttributer) *HTTPClient
- func GET(attrs ...HTTPClientAttributer) *HTTPClient
- func HEAD(attrs ...HTTPClientAttributer) *HTTPClient
- func New(attrs ...HTTPClientAttributer) *HTTPClient
- func OPTIONS(attrs ...HTTPClientAttributer) *HTTPClient
- func PATCH(attrs ...HTTPClientAttributer) *HTTPClient
- func POST(attrs ...HTTPClientAttributer) *HTTPClient
- func PUT(attrs ...HTTPClientAttributer) *HTTPClient
- func TRACE(attrs ...HTTPClientAttributer) *HTTPClient
- func (my *HTTPClient) Error() error
- func (my *HTTPClient) GetBody() []byte
- func (my *HTTPClient) GetCert() []byte
- func (my *HTTPClient) GetClient() *http.Client
- func (my *HTTPClient) GetHeaders() http.Header
- func (my *HTTPClient) GetMethod() string
- func (my *HTTPClient) GetQueries() map[string]string
- func (my *HTTPClient) GetRawRequest() *http.Request
- func (my *HTTPClient) GetRawResponse() *http.Response
- func (my *HTTPClient) GetStatus() string
- func (my *HTTPClient) GetStatusCode() int
- func (my *HTTPClient) GetTimeout() time.Duration
- func (my *HTTPClient) GetTransport() *http.Transport
- func (my *HTTPClient) GetURL() string
- func (my *HTTPClient) Release()
- func (my *HTTPClient) Send() *HTTPClient
- func (my *HTTPClient) SendWithRetry(count uint, interval time.Duration, ...) *HTTPClient
- func (my *HTTPClient) SetAttrs(attrs ...HTTPClientAttributer) *HTTPClient
- func (my *HTTPClient) ToBytes() []byte
- func (my *HTTPClient) ToJSON(target any, keys ...any) *HTTPClient
- func (my *HTTPClient) ToWriter(writer http.ResponseWriter) *HTTPClient
- func (my *HTTPClient) ToXML(target any) *HTTPClient
- type HTTPClientAttributer
- type HTTPClientBuilder
Constants ¶
View Source
const ( ContentTypeJSON ContentType = "application/json" ContentTypeXML ContentType = "application/xml" ContentTypeXWwwFormURLencoded ContentType = "application/x-www-form-urlencoded" ContentTypeFormData ContentType = "multipart/form-data" ContentTypePlain ContentType = "text/plain" ContentTypeHTML ContentType = "text/html" ContentTypeCSS ContentType = "text/css" ContentTypeJavascript ContentType = "text/javascript" ContentTypeSteam ContentType = "application/octet-stream" AcceptJSON Accept = "application/json" AcceptXML Accept = "application/xml" AcceptPlain Accept = "text/plain" AcceptHTML Accept = "text/html" AcceptCSS Accept = "text/css" AcceptJavascript Accept = "text/javascript" AcceptSteam Accept = "application/octet-stream" AcceptAny Accept = "*/*" )
Variables ¶
View Source
var APP = &app{}
Functions ¶
This section is empty.
Types ¶
type AttrAccept ¶
type AttrAccept struct {
// contains filtered or unexported fields
}
func Accept_ ¶
func Accept_(accept Accept) *AttrAccept
func (*AttrAccept) Apply ¶
func (a *AttrAccept) Apply(client *HTTPClient)
type AttrAuthorization ¶
type AttrAuthorization struct {
// contains filtered or unexported fields
}
func Authorization ¶
func Authorization(username, password, title string) *AttrAuthorization
func (*AttrAuthorization) Apply ¶
func (a *AttrAuthorization) Apply(client *HTTPClient)
type AttrAutoCopy ¶
type AttrAutoCopy struct {
// contains filtered or unexported fields
}
func AutoCopy ¶
func AutoCopy(autoCopy bool) *AttrAutoCopy
func (*AttrAutoCopy) Apply ¶
func (a *AttrAutoCopy) Apply(client *HTTPClient)
type AttrBody ¶
type AttrBody struct {
// contains filtered or unexported fields
}
func Javascript ¶
func Reader ¶
func Reader(body io.ReadCloser) *AttrBody
func (*AttrBody) Apply ¶
func (a *AttrBody) Apply(client *HTTPClient)
type AttrCert ¶
type AttrCert struct {
// contains filtered or unexported fields
}
func (*AttrCert) Apply ¶
func (a *AttrCert) Apply(client *HTTPClient)
type AttrContentType ¶
type AttrContentType struct {
// contains filtered or unexported fields
}
func ContentType_ ¶
func ContentType_(ct ContentType) *AttrContentType
func (*AttrContentType) Apply ¶
func (a *AttrContentType) Apply(client *HTTPClient)
type AttrHeader ¶
type AttrHeader struct {
// contains filtered or unexported fields
}
func AppendHeader ¶
func AppendHeader(key string, values ...string) *AttrHeader
func AppendHeaders ¶
func AppendHeaders(headers http.Header) *AttrHeader
func SetHeader ¶
func SetHeader(key string, values ...string) *AttrHeader
func SetHeaders ¶
func SetHeaders(headers http.Header) *AttrHeader
func (*AttrHeader) Apply ¶
func (a *AttrHeader) Apply(client *HTTPClient)
type AttrMethod ¶
type AttrMethod struct {
// contains filtered or unexported fields
}
func Method ¶
func Method(method string) *AttrMethod
func (*AttrMethod) Apply ¶
func (a *AttrMethod) Apply(client *HTTPClient)
type AttrQueries ¶
type AttrQueries struct {
// contains filtered or unexported fields
}
func Queries ¶
func Queries(queries map[string]string) *AttrQueries
func (*AttrQueries) Append ¶
func (a *AttrQueries) Append(queries map[string]string) *AttrQueries
func (*AttrQueries) AppendOne ¶
func (a *AttrQueries) AppendOne(key, value string) *AttrQueries
func (*AttrQueries) Apply ¶
func (a *AttrQueries) Apply(client *HTTPClient)
type AttrTimeout ¶
type AttrTimeout struct {
// contains filtered or unexported fields
}
func Timeout ¶
func Timeout(timeout time.Duration) *AttrTimeout
func (*AttrTimeout) Apply ¶
func (a *AttrTimeout) Apply(client *HTTPClient)
type AttrTransport ¶
type AttrTransport struct {
// contains filtered or unexported fields
}
func Transport ¶
func Transport(transport *http.Transport) *AttrTransport
func TransportDefault ¶
func TransportDefault() *AttrTransport
func (*AttrTransport) Apply ¶
func (a *AttrTransport) Apply(client *HTTPClient)
type AttrURL ¶
type AttrURL struct {
// contains filtered or unexported fields
}
func (*AttrURL) Apply ¶
func (a *AttrURL) Apply(client *HTTPClient)
type ContentType ¶
type ContentType string
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func DELETE ¶
func DELETE(attrs ...HTTPClientAttributer) *HTTPClient
func GET ¶
func GET(attrs ...HTTPClientAttributer) *HTTPClient
func HEAD ¶
func HEAD(attrs ...HTTPClientAttributer) *HTTPClient
func New ¶
func New(attrs ...HTTPClientAttributer) *HTTPClient
func OPTIONS ¶
func OPTIONS(attrs ...HTTPClientAttributer) *HTTPClient
func PATCH ¶
func PATCH(attrs ...HTTPClientAttributer) *HTTPClient
func POST ¶
func POST(attrs ...HTTPClientAttributer) *HTTPClient
func PUT ¶
func PUT(attrs ...HTTPClientAttributer) *HTTPClient
func TRACE ¶
func TRACE(attrs ...HTTPClientAttributer) *HTTPClient
func (*HTTPClient) Error ¶
func (my *HTTPClient) Error() error
func (*HTTPClient) GetBody ¶
func (my *HTTPClient) GetBody() []byte
func (*HTTPClient) GetCert ¶
func (my *HTTPClient) GetCert() []byte
func (*HTTPClient) GetClient ¶
func (my *HTTPClient) GetClient() *http.Client
func (*HTTPClient) GetHeaders ¶
func (my *HTTPClient) GetHeaders() http.Header
func (*HTTPClient) GetMethod ¶
func (my *HTTPClient) GetMethod() string
func (*HTTPClient) GetQueries ¶
func (my *HTTPClient) GetQueries() map[string]string
func (*HTTPClient) GetRawRequest ¶
func (my *HTTPClient) GetRawRequest() *http.Request
func (*HTTPClient) GetRawResponse ¶
func (my *HTTPClient) GetRawResponse() *http.Response
func (*HTTPClient) GetStatus ¶
func (my *HTTPClient) GetStatus() string
func (*HTTPClient) GetStatusCode ¶
func (my *HTTPClient) GetStatusCode() int
func (*HTTPClient) GetTimeout ¶
func (my *HTTPClient) GetTimeout() time.Duration
func (*HTTPClient) GetTransport ¶
func (my *HTTPClient) GetTransport() *http.Transport
func (*HTTPClient) GetURL ¶
func (my *HTTPClient) GetURL() string
func (*HTTPClient) Send ¶
func (my *HTTPClient) Send() *HTTPClient
func (*HTTPClient) SendWithRetry ¶
func (my *HTTPClient) SendWithRetry(count uint, interval time.Duration, condition func(statusCode int, err error) bool) *HTTPClient
func (*HTTPClient) SetAttrs ¶
func (my *HTTPClient) SetAttrs(attrs ...HTTPClientAttributer) *HTTPClient
func (*HTTPClient) ToBytes ¶
func (my *HTTPClient) ToBytes() []byte
func (*HTTPClient) ToJSON ¶
func (my *HTTPClient) ToJSON(target any, keys ...any) *HTTPClient
func (*HTTPClient) ToWriter ¶
func (my *HTTPClient) ToWriter(writer http.ResponseWriter) *HTTPClient
func (*HTTPClient) ToXML ¶
func (my *HTTPClient) ToXML(target any) *HTTPClient
type HTTPClientAttributer ¶
type HTTPClientAttributer interface {
Apply(client *HTTPClient)
}
HTTPClientAttributer 接口 - 简化接口减少逃逸
type HTTPClientBuilder ¶
type HTTPClientBuilder struct {
// contains filtered or unexported fields
}
func (*HTTPClientBuilder) GetClient ¶
func (my *HTTPClientBuilder) GetClient() *HTTPClient
func (*HTTPClientBuilder) New ¶
func (*HTTPClientBuilder) New(attrs ...HTTPClientAttributer) *HTTPClientBuilder
Click to show internal directories.
Click to hide internal directories.