requests

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(baseURL string, params *url.Values) (*models.Response, error)

Delete 发送 DELETE 请求

func Get

func Get(baseURL string, params *url.Values) (*models.Response, error)

Get 发送 GET 请求

func GetTransport added in v0.0.2

func GetTransport(enableHTTP2 bool) *http.Transport

func IsHTTP2Enabled

func IsHTTP2Enabled() bool

IsHTTP2Enabled 获取全局 HTTP/2 启用状态

func Patch

func Patch(baseURL string, form *url.Values) (*models.Response, error)

Patch 发送 PATCH 请求

func Post

func Post(baseURL string, form *url.Values) (*models.Response, error)

func Put

func Put(baseURL string, form *url.Values) (*models.Response, error)

Put 发送 PUT 请求

func PutTransport added in v0.0.2

func PutTransport(transport *http.Transport)

func SetHTTP2Enabled

func SetHTTP2Enabled(enabled bool)

SetHTTP2Enabled 设置全局 HTTP/2 启用状态,并更新默认 Session

Types

type Client

type Client interface {
	Do(req *Request) (*models.Response, error)
	Clone() Client
}

type Request

type Request struct {
	Method  string
	URL     *neturl.URL
	Headers http.Header
	Body    io.Reader
	Params  *customurl.Values
}

func NewRequest

func NewRequest(method, rawURL string, params *customurl.Values, body io.Reader) (*Request, error)

func (*Request) AddHeader

func (r *Request) AddHeader(key, value string)

type Session

type Session interface {
	Client
	WithBaseURL(base string) Session
	WithTimeout(d time.Duration) Session
	WithProxy(proxyURL string) Session
	WithDNS(dnsServers []string) Session
	WithHeader(key, value string) Session
	WithHTTP2(enabled bool) Session
	WithKeepAlive(enabled bool) Session
	WithMaxIdleConns(maxIdle int) Session
	Close() error
	Clear() Session
}

func NewSession

func NewSession() Session

NewSession 创建一个新的 Session,使用对应的 Transport 池

Jump to

Keyboard shortcuts

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