curlpkg

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

README

curl

可参考文档:github.com/go-resty/resty

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout timeout
	DefaultTimeout = time.Minute

	// ContentType header
	ContentType         = "Content-Type"
	ContentTypeJSON     = "application/json"
	ContentTypeJSONUtf8 = "application/json; charset=utf-8"
	ContentTypePB       = "application/x-protobuf"

	// UserAgent Accept header
	UserAgent = "User-Agent"
)

Variables

This section is empty.

Functions

func Default

func Default(httpReq *http.Request) (httpCode int, bodyBytes []byte, err error)

Default http.DefaultClient

func Do

func Do(httpReq *http.Request, opts ...Option) (httpCode int, bodyBytes []byte, err error)

Do 请求

func DoWithClient

func DoWithClient(httpClient *http.Client, httpReq *http.Request) (httpCode int, bodyBytes []byte, err error)

DoWithClient 请求一次后关闭连接

func ErrRequestFailure

func ErrRequestFailure(code int) error

ErrRequestFailure ...

func IsSuccessCode

func IsSuccessCode(code int) bool

IsSuccessCode .

func NewGetRequest

func NewGetRequest(httpURL string, body io.Reader) (httpReq *http.Request, err error)

NewGetRequest Get请求

func NewHTTPClient

func NewHTTPClient(opts ...Option) *http.Client

NewHTTPClient http客户端

func NewPostRequest

func NewPostRequest(httpURL string, body io.Reader) (httpReq *http.Request, err error)

NewPostRequest Post请求

func NewRequest

func NewRequest(httpMethod, httpURL string, body io.Reader) (httpReq *http.Request, err error)

NewRequest .

Types

type Option

type Option func(*options)

Option is config option.

func WithTimeout

func WithTimeout(duration time.Duration) Option

WithTimeout http.Client.Timeout

func WithTimeoutDefault

func WithTimeoutDefault() Option

WithTimeoutDefault 默认时间选项

Jump to

Keyboard shortcuts

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