httpClientV3

package
v1.51.9 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 21 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
}

Functions

This section is empty.

Types

type Accept

type Accept string

type AttrAppendHeaderValue

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

func AppendHeaderValue

func AppendHeaderValue(headers map[string]any) AttrAppendHeaderValue

func (AttrAppendHeaderValue) Accept

func (AttrAppendHeaderValue) Append

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

func (AttrAppendHeaderValue) AppendOne

func (my AttrAppendHeaderValue) AppendOne(key string, value any) 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) ImplHTTPClientAttributer

func (AttrAppendHeaderValue) ImplHTTPClientAttributer()

func (AttrAppendHeaderValue) Register

func (my AttrAppendHeaderValue) Register(req *HTTPClient)

type AttrAppendHeaderValues

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

func AppendHeaderValues

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

func (AttrAppendHeaderValues) Accept

func (AttrAppendHeaderValues) Append

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

func (AttrAppendHeaderValues) AppendOne

func (my AttrAppendHeaderValues) AppendOne(key string, values ...any) 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) ImplHTTPClientAttributer

func (AttrAppendHeaderValues) ImplHTTPClientAttributer()

func (AttrAppendHeaderValues) Register

func (my AttrAppendHeaderValues) Register(req *HTTPClient)

type AttrAutoCopyResBody

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

func AutoCopy

func AutoCopy(autoCopy bool) AttrAutoCopyResBody

func (AttrAutoCopyResBody) Error

func (AttrAutoCopyResBody) Error() error

func (AttrAutoCopyResBody) ImplHTTPClientAttributer

func (AttrAutoCopyResBody) ImplHTTPClientAttributer()

func (AttrAutoCopyResBody) Register

func (my AttrAutoCopyResBody) Register(req *HTTPClient)

type AttrAutoLock

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

func AutoLock

func AutoLock(autoLock bool) AttrAutoLock

func (AttrAutoLock) Error

func (AttrAutoLock) Error() error

func (AttrAutoLock) ImplHTTPClientAttributer

func (AttrAutoLock) ImplHTTPClientAttributer()

func (AttrAutoLock) Register

func (my AttrAutoLock) Register(req *HTTPClient)

type AttrBody

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

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

func (AttrBody) ImplHTTPClientAttributer()

func (AttrBody) Register

func (my AttrBody) Register(req *HTTPClient)

type AttrCert

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

func Cert

func Cert(cert []byte) AttrCert

func (AttrCert) Error

func (my AttrCert) Error() error

func (AttrCert) ImplHTTPClientAttributer

func (AttrCert) ImplHTTPClientAttributer()

func (AttrCert) Register

func (my AttrCert) Register(req *HTTPClient)

type AttrMethod

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

func Method

func Method(method string) AttrMethod

func (AttrMethod) Error

func (my AttrMethod) Error() error

func (AttrMethod) ImplHTTPClientAttributer

func (AttrMethod) ImplHTTPClientAttributer()

func (AttrMethod) Register

func (my AttrMethod) Register(req *HTTPClient)

type AttrQueries

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

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

func (AttrQueries) ImplHTTPClientAttributer()

func (AttrQueries) Register

func (my AttrQueries) Register(req *HTTPClient)

type AttrSetHeaderValue

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

func SetHeaderValue

func SetHeaderValue(headers map[string]any) 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) ImplHTTPClientAttributer

func (AttrSetHeaderValue) ImplHTTPClientAttributer()

func (AttrSetHeaderValue) Register

func (my AttrSetHeaderValue) Register(req *HTTPClient)

type AttrSetHeaderValues

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

func SetHeaderValues

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

func (AttrSetHeaderValues) Accept

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

func (AttrSetHeaderValues) ImplHTTPClientAttributer()

func (AttrSetHeaderValues) Register

func (my AttrSetHeaderValues) Register(req *HTTPClient)

type AttrTimeout

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

func Timeout

func Timeout(timeout time.Duration) AttrTimeout

func (AttrTimeout) Error

func (AttrTimeout) Error() error

func (AttrTimeout) ImplHTTPClientAttributer

func (AttrTimeout) ImplHTTPClientAttributer()

func (AttrTimeout) Register

func (my AttrTimeout) Register(req *HTTPClient)

type AttrTransport

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

func Transport

func Transport(transport *http.Transport) AttrTransport

func (AttrTransport) Error

func (my AttrTransport) Error() error

func (AttrTransport) ImplHTTPClientAttributer

func (AttrTransport) ImplHTTPClientAttributer()

func (AttrTransport) Register

func (my AttrTransport) Register(req *HTTPClient)

type AttrTransportDefault

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

func TransportDefault

func TransportDefault() *AttrTransportDefault

func (AttrTransportDefault) Error

func (my AttrTransportDefault) Error() error

func (AttrTransportDefault) ImplHTTPClientAttributer

func (AttrTransportDefault) ImplHTTPClientAttributer()

func (AttrTransportDefault) Register

func (my AttrTransportDefault) Register(req *HTTPClient)

type AttrURL

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

func (AttrURL) Error

func (my AttrURL) Error() error

func (AttrURL) ImplHTTPClientAttributer

func (AttrURL) ImplHTTPClientAttributer()

func (AttrURL) Register

func (my AttrURL) Register(req *HTTPClient)

type ContentType

type ContentType string

type HTTPClient

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

func (HTTPClient) DELETE

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

DELETE 实例化:HTTP客户端 - DELETE请求

func (HTTPClient) Error

func (my HTTPClient) Error() (err error)

Error 获取错误信息

func (HTTPClient) GET

GET 实例化:HTTP客户端 - GET请求

func (HTTPClient) GetBody

func (my HTTPClient) GetBody() []byte

GetBody 获取请求体

func (HTTPClient) GetCert

func (my HTTPClient) GetCert() []byte

GetCert 获取TLS证书

func (HTTPClient) GetClient

func (my HTTPClient) GetClient() *http.Client

GetClient 获取HTTP客户端

func (HTTPClient) GetHeaders

func (my HTTPClient) GetHeaders() map[string][]any

GetHeaders 获取请求头

func (HTTPClient) GetMethod

func (my HTTPClient) GetMethod() string

GetMethod 获取请求方法

func (HTTPClient) GetQueries

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

GetQueries 获取请求查询参数

func (HTTPClient) GetRawRequest

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

GetRawRequest 获取原始HTTP请求

func (HTTPClient) GetRawResponse

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

GetRawResponse 获取原始HTTP响应

func (HTTPClient) GetTimeout

func (my HTTPClient) GetTimeout() time.Duration

GetTimeout 获取请求超时时间

func (HTTPClient) GetTransport

func (my HTTPClient) GetTransport() *http.Transport

GetTransport 获取HTTP传输配置

func (HTTPClient) GetURL

func (my HTTPClient) GetURL() string

GetURL 获取完整请求URL

func (HTTPClient) HEAD

HEAD 实例化:HTTP客户端 - HEAD请求

func (HTTPClient) Lock

func (my HTTPClient) Lock() HTTPClient

Lock 加锁 - 写锁

func (HTTPClient) New

New 实例化:HTTP客户端

func (HTTPClient) OPTIONS

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

OPTIONS 实例化:HTTP客户端 - OPTIONS请求

func (HTTPClient) PATCH

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

PATCH 实例化:HTTP客户端 - PATCH请求

func (HTTPClient) POST

POST 实例化:HTTP客户端 - POST请求

func (HTTPClient) PUT

PUT 实例化:HTTP客户端 - PUT请求

func (HTTPClient) RLock

func (my HTTPClient) RLock() HTTPClient

RLock 加锁 - 读锁

func (HTTPClient) RUnlock

func (my HTTPClient) RUnlock() HTTPClient

RUnlock 解锁 - 读锁

func (HTTPClient) Send

func (my HTTPClient) Send() HTTPClient

Send 发送HTTP请求(线程安全)

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

SetAttrs 设置属性(线程安全)

func (HTTPClient) TRACE

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

TRACE 实例化:HTTP客户端 - TRACE请求

func (HTTPClient) ToBytes

func (my HTTPClient) ToBytes() []byte

ToBytes 将响应体转换为字节切片

func (HTTPClient) ToJSON

func (my HTTPClient) ToJSON(target any, keys ...any) HTTPClient

ToJSON 将响应体转换为JSON对象

func (HTTPClient) ToWriter

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

ToWriter 将响应体写入HTTP响应写入器

func (HTTPClient) ToXML

func (my HTTPClient) ToXML(target any) HTTPClient

ToXML 将响应体转换为XML对象

func (HTTPClient) Unlock

func (my HTTPClient) Unlock() HTTPClient

Unlock 解锁 - 写锁

type HTTPClientAttributer

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

func URL

func URL(urls ...any) HTTPClientAttributer

func XML

func XML(body any) HTTPClientAttributer

Jump to

Keyboard shortcuts

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