httpClientV3

package
v1.47.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContentTypeJSON               ContentType = "json"
	ContentTypeXML                ContentType = "xml"
	ContentTypeXWwwFormURLencoded ContentType = "form"
	ContentTypeFormData           ContentType = "form-data"
	ContentTypePlain              ContentType = "plain"
	ContentTypeHTML               ContentType = "html"
	ContentTypeCSS                ContentType = "css"
	ContentTypeJavascript         ContentType = "javascript"
	ContentTypeSteam              ContentType = "steam"

	ContentTypes = map[ContentType]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       Accept = "json"
	AcceptXML        Accept = "xml"
	AcceptPlain      Accept = "plain"
	AcceptHTML       Accept = "html"
	AcceptCSS        Accept = "css"
	AcceptJavascript Accept = "javascript"
	AcceptSteam      Accept = "steam"
	AcceptAny        Accept = "any"

	Accepts = map[Accept]string{
		AcceptJSON:       "application/json",
		AcceptXML:        "application/xml",
		AcceptPlain:      "text/plain",
		AcceptHTML:       "text/html",
		AcceptCSS:        "text/css",
		AcceptJavascript: "text/javascript",
		AcceptSteam:      "application/octet-stream",
		AcceptAny:        "*/*",
	}
)
View Source
var APP struct {
	HTTPClient        HTTPClient
	HTTPClientBuilder HTTPClientBuilder
}

Functions

This section is empty.

Types

type Accept

type Accept string

type AttrAppendHeaderValue

type AttrAppendHeaderValue struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func AppendHeaderValue

func AppendHeaderValue(headers map[string]string) *AttrAppendHeaderValue

func (*AttrAppendHeaderValue) Accept

func (*AttrAppendHeaderValue) Append

func (my *AttrAppendHeaderValue) Append(headers map[string]string) *AttrAppendHeaderValue

func (*AttrAppendHeaderValue) AppendOne

func (my *AttrAppendHeaderValue) AppendOne(key string, value string) *AttrAppendHeaderValue

func (*AttrAppendHeaderValue) Authorization

func (my *AttrAppendHeaderValue) Authorization(username, password, title string) *AttrAppendHeaderValue

func (*AttrAppendHeaderValue) ContentType

func (my *AttrAppendHeaderValue) ContentType(contentType ContentType) *AttrAppendHeaderValue

func (*AttrAppendHeaderValue) Error

func (my *AttrAppendHeaderValue) Error() error

func (*AttrAppendHeaderValue) Register

func (my *AttrAppendHeaderValue) Register(req *HTTPClient)

type AttrAppendHeaderValues

type AttrAppendHeaderValues struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func AppendHeaderValues

func AppendHeaderValues(headers map[string][]string) *AttrAppendHeaderValues

func (*AttrAppendHeaderValues) Accept

func (*AttrAppendHeaderValues) Append

func (my *AttrAppendHeaderValues) Append(headers map[string][]string) *AttrAppendHeaderValues

func (*AttrAppendHeaderValues) AppendOne

func (my *AttrAppendHeaderValues) AppendOne(key string, values ...string) *AttrAppendHeaderValues

func (*AttrAppendHeaderValues) Authorization

func (my *AttrAppendHeaderValues) Authorization(username, password, title string) *AttrAppendHeaderValues

func (*AttrAppendHeaderValues) ContentType

func (my *AttrAppendHeaderValues) ContentType(contentType ContentType) *AttrAppendHeaderValues

func (*AttrAppendHeaderValues) Error

func (my *AttrAppendHeaderValues) Error() error

func (*AttrAppendHeaderValues) Register

func (my *AttrAppendHeaderValues) Register(req *HTTPClient)

type AttrAutoCopyResBody

type AttrAutoCopyResBody struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func AutoCopy

func AutoCopy(autoCopy bool) *AttrAutoCopyResBody

func (*AttrAutoCopyResBody) Error

func (*AttrAutoCopyResBody) Error() error

func (*AttrAutoCopyResBody) Register

func (my *AttrAutoCopyResBody) Register(req *HTTPClient)

type AttrBody

type AttrBody struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func Bytes

func Bytes(body []byte) *AttrBody

func CSS

func CSS(body string) *AttrBody

func File

func File(filename string) *AttrBody

func Form

func Form(body map[string]any) *AttrBody

func FormData

func FormData(fields, files map[string]string) *AttrBody

func FormSlice added in v1.47.5

func FormSlice(bodies []FormItem) *AttrBody

func HTML

func HTML(body string) *AttrBody

func JSON

func JSON(body any) *AttrBody

func Javascript

func Javascript(body string) *AttrBody

func Plain

func Plain(body string) *AttrBody

func Reader

func Reader(body io.ReadCloser) *AttrBody

func (*AttrBody) Error

func (my *AttrBody) Error() error

func (*AttrBody) Register

func (my *AttrBody) Register(req *HTTPClient)

type AttrCert

type AttrCert struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func Cert

func Cert(cert []byte) *AttrCert

func (*AttrCert) Error

func (my *AttrCert) Error() error

func (*AttrCert) Register

func (my *AttrCert) Register(req *HTTPClient)

type AttrMethod

type AttrMethod struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func Method

func Method(method string) *AttrMethod

func (*AttrMethod) Error

func (my *AttrMethod) Error() error

func (*AttrMethod) Register

func (my *AttrMethod) Register(req *HTTPClient)

type AttrQueries

type AttrQueries struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func Queries

func Queries(queries map[string]any) *AttrQueries

func (*AttrQueries) Append

func (my *AttrQueries) Append(queries map[string]any) *AttrQueries

func (*AttrQueries) AppendOne

func (my *AttrQueries) AppendOne(key string, value any) *AttrQueries

func (*AttrQueries) Error

func (my *AttrQueries) Error() error

func (*AttrQueries) Register

func (my *AttrQueries) Register(req *HTTPClient)

type AttrRetryCondition added in v1.47.2

type AttrRetryCondition struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func RetryCondition added in v1.47.2

func RetryCondition(retryCondition func(statusCode int, err error) bool) AttrRetryCondition

func (AttrRetryCondition) Error added in v1.47.2

func (my AttrRetryCondition) Error() error

func (AttrRetryCondition) Register added in v1.47.2

func (my AttrRetryCondition) Register(httpClient *HTTPClient)

type AttrRetryCount added in v1.47.2

type AttrRetryCount struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func RetryCount added in v1.47.2

func RetryCount(count uint) AttrRetryCount

func (AttrRetryCount) Error added in v1.47.2

func (my AttrRetryCount) Error() error

func (AttrRetryCount) Register added in v1.47.2

func (my AttrRetryCount) Register(httpClient *HTTPClient)

type AttrRetryInterval added in v1.47.2

type AttrRetryInterval struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func RetryInterval added in v1.47.2

func RetryInterval(interval time.Duration) AttrRetryInterval

func (AttrRetryInterval) Error added in v1.47.2

func (my AttrRetryInterval) Error() error

func (AttrRetryInterval) Register added in v1.47.2

func (my AttrRetryInterval) Register(httpClient *HTTPClient)

type AttrSetHeaderValue

type AttrSetHeaderValue struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func SetHeaderValue

func SetHeaderValue(headers map[string]string) *AttrSetHeaderValue

func (*AttrSetHeaderValue) Accept

func (my *AttrSetHeaderValue) Accept(accept Accept) *AttrSetHeaderValue

func (*AttrSetHeaderValue) Authorization

func (my *AttrSetHeaderValue) Authorization(username, password, title string) *AttrSetHeaderValue

func (*AttrSetHeaderValue) ContentType

func (my *AttrSetHeaderValue) ContentType(contentType ContentType) *AttrSetHeaderValue

func (*AttrSetHeaderValue) Error

func (my *AttrSetHeaderValue) Error() error

func (*AttrSetHeaderValue) Register

func (my *AttrSetHeaderValue) Register(req *HTTPClient)

type AttrSetHeaderValues

type AttrSetHeaderValues struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func SetHeaderValues

func SetHeaderValues(headers map[string][]string) *AttrSetHeaderValues

func (*AttrSetHeaderValues) Accept

func (my *AttrSetHeaderValues) Accept(accept Accept) *AttrSetHeaderValues

func (*AttrSetHeaderValues) Authorization

func (my *AttrSetHeaderValues) Authorization(username, password, title string) *AttrSetHeaderValues

func (*AttrSetHeaderValues) ContentType

func (my *AttrSetHeaderValues) ContentType(contentType ContentType) *AttrSetHeaderValues

func (*AttrSetHeaderValues) Error

func (my *AttrSetHeaderValues) Error() error

func (*AttrSetHeaderValues) Register

func (my *AttrSetHeaderValues) Register(req *HTTPClient)

type AttrTimeout

type AttrTimeout struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func Timeout

func Timeout(timeout time.Duration) *AttrTimeout

func (*AttrTimeout) Error

func (*AttrTimeout) Error() error

func (*AttrTimeout) Register

func (my *AttrTimeout) Register(req *HTTPClient)

type AttrTransport

type AttrTransport struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func Transport

func Transport(transport *http.Transport) *AttrTransport

func (*AttrTransport) Error

func (my *AttrTransport) Error() error

func (*AttrTransport) Register

func (my *AttrTransport) Register(req *HTTPClient)

type AttrTransportDefault

type AttrTransportDefault struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func TransportDefault

func TransportDefault() *AttrTransportDefault

func (*AttrTransportDefault) Error

func (my *AttrTransportDefault) Error() error

func (*AttrTransportDefault) Register

func (my *AttrTransportDefault) Register(req *HTTPClient)

type AttrURL

type AttrURL struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func (*AttrURL) Error

func (my *AttrURL) Error() error

func (*AttrURL) Register

func (my *AttrURL) Register(req *HTTPClient)

type ContentType

type ContentType string

type FormItem added in v1.47.5

type FormItem struct {
	Key string
	Val any
}

******************** HTTP客户端属性 ******************** //

type FormItems added in v1.47.5

type FormItems struct {
	// contains filtered or unexported fields
}

******************** HTTP客户端属性 ******************** //

func (*FormItems) Add added in v1.47.5

func (my *FormItems) Add(key string, val any) *FormItems

func (*FormItems) New added in v1.47.5

func (my *FormItems) New() *FormItems

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

func (*HTTPClient) DELETE

func (*HTTPClient) DELETE(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) Error

func (my *HTTPClient) Error() error

func (*HTTPClient) GET

func (*HTTPClient) GET(attrs ...HTTPClientAttributer) *HTTPClient

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() map[string][]string

func (*HTTPClient) GetMethod

func (my *HTTPClient) GetMethod() string

func (*HTTPClient) GetQueries

func (my *HTTPClient) GetQueries() map[string]any

func (*HTTPClient) GetRawRequest

func (my *HTTPClient) GetRawRequest() *http.Request

func (*HTTPClient) GetRawResponse

func (my *HTTPClient) GetRawResponse() *http.Response

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) HEAD

func (*HTTPClient) HEAD(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) New

func (*HTTPClient) New(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) OPTIONS

func (*HTTPClient) OPTIONS(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) PATCH

func (*HTTPClient) PATCH(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) POST

func (*HTTPClient) POST(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) PUT

func (*HTTPClient) PUT(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) Send

func (my *HTTPClient) Send(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) SendWithRetry

func (my *HTTPClient) SendWithRetry(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) SetAttrs

func (my *HTTPClient) SetAttrs(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) TRACE

func (*HTTPClient) TRACE(attrs ...HTTPClientAttributer) *HTTPClient

func (*HTTPClient) ToBytes

func (my *HTTPClient) ToBytes() []byte

func (*HTTPClient) ToJson added in v1.47.0

func (my *HTTPClient) ToJson(target any, keys ...any) *HTTPClient

func (*HTTPClient) ToWriter

func (my *HTTPClient) ToWriter(writer http.ResponseWriter) *HTTPClient

func (*HTTPClient) ToXml added in v1.47.0

func (my *HTTPClient) ToXml(target any) *HTTPClient

type HTTPClientAttributer

type HTTPClientAttributer interface {
	Register(req *HTTPClient)
	Error() error
}

******************** HTTP客户端属性 ******************** //

func URL

func URL(urls ...string) HTTPClientAttributer

func XML

func XML(body any) HTTPClientAttributer

type HTTPClientBuilder added in v1.47.0

type HTTPClientBuilder struct {
	// contains filtered or unexported fields
}

func (*HTTPClientBuilder) GetClient added in v1.47.0

func (my *HTTPClientBuilder) GetClient() *HTTPClient

func (*HTTPClientBuilder) New added in v1.47.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL