v0.0.0-...-fa91634 Latest Latest

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 21 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Opt

type Opt func(*Options)


func WithBaseURI

func WithBaseURI(data string) Opt

设置 BaseURI

func WithBody

func WithBody(data any) Opt

设置 Body

func WithCookies

func WithCookies(data any) Opt

设置 Cookies

func WithHeaders

func WithHeaders(data map[string]any) Opt

设置 Headers

func WithMaxConnsPerHost

func WithMaxConnsPerHost(data int) Opt

设置 MaxConnsPerHost

func WithMaxIdleConns

func WithMaxIdleConns(data int) Opt

设置 MaxIdleConns

func WithMaxIdleConnsPerHost

func WithMaxIdleConnsPerHost(data int) Opt

设置 MaxIdleConnsPerHost

func WithParams

func WithParams(data map[string]any) Opt

设置 Params

func WithProxy

func WithProxy(data string) Opt

设置 Proxy

func WithResCharset

func WithResCharset(data string) Opt

设置 ResCharset 可选值(GB18030、GBK、utf-8等)

func WithTimeout

func WithTimeout(data float32) Opt

设置 Timeout

type Options

type Options struct {
	Headers    map[string]any
	BaseURI    string
	Params     map[string]any
	Body       any
	Timeout    float32
	Cookies    any
	Proxy      string
	ResCharset string

	MaxIdleConns        int
	MaxConnsPerHost     int
	MaxIdleConnsPerHost int


  • 选项 *
  • @create 2022-6-29
  • @author deatil

type Request

type Request struct {
	Params string
	// contains filtered or unexported fields


  • 请求 *
  • @create 2022-6-29
  • @author deatil

func CreateClient

func CreateClient(opts ...Opt) *Request

创建一个 HttpClient 客户端用于发送请求

func New

func New(opts ...Opt) *Request

创建一个 HttpClient 客户端

func (*Request) Delete

func (this *Request) Delete(uri string, opts ...Opt) (*Response, error)

Delete send delete request

func (*Request) Download

func (this *Request) Download(resourceUrl string, savePath, saveName string, opts ...Opt) (bool, error)

Get method download files

func (*Request) Get

func (this *Request) Get(uri string, opts ...Opt) (*Response, error)

Get send get request

func (*Request) Options

func (this *Request) Options(uri string, opts ...Opt) (*Response, error)

Options send options request

func (*Request) Patch

func (this *Request) Patch(uri string, opts ...Opt) (*Response, error)

Patch send patch request

func (*Request) Post

func (this *Request) Post(uri string, opts ...Opt) (*Response, error)

Post send post request

func (*Request) Put

func (this *Request) Put(uri string, opts ...Opt) (*Response, error)

Put send put request

func (*Request) Request

func (this *Request) Request(method string, uri string, opts ...Opt) (*Response, error)

Request send request

func (*Request) SimpleChineseToUtf8

func (this *Request) SimpleChineseToUtf8(vBytes []byte) string

(接受到的)简体中文 转换为 utf-8

func (*Request) ToString

func (this *Request) ToString(i interface{}) string


func (*Request) Utf8ToSimpleChinese

func (this *Request) Utf8ToSimpleChinese(vBytes []byte, charset ...string) string

(一般是go 语言发送的数据)utf-8 转换为 简体中文发出去

type Response

type Response struct {
	// contains filtered or unexported fields


  • 响应 *
  • @create 2022-6-29
  • @author deatil

func (*Response) GetBody

func (this *Response) GetBody() io.ReadCloser

GetBody parse response body

func (*Response) GetContentLength

func (this *Response) GetContentLength() int64

Get Response ContentLength

func (*Response) GetContents

func (this *Response) GetContents() (bodyStr string, err error)


func (*Response) GetCookie

func (this *Response) GetCookie(cookieName string) *http.Cookie


func (*Response) GetCookies

func (this *Response) GetCookies() []*http.Cookie


func (*Response) GetHeader

func (this *Response) GetHeader(name string) []string

GetHeader get response header

func (*Response) GetHeaderLine

func (this *Response) GetHeaderLine(name string) string

GetHeaderLine get a single response header

func (*Response) GetHeaders

func (this *Response) GetHeaders() map[string][]string

GetHeaders get response headers

func (*Response) GetReasonPhrase

func (this *Response) GetReasonPhrase() string

GetReasonPhrase get response reason phrase

func (*Response) GetRequest

func (this *Response) GetRequest() *http.Request

GetRequest get request object

func (*Response) GetResponse

func (this *Response) GetResponse() *http.Response

GetRequest get request object

func (*Response) GetStatusCode

func (this *Response) GetStatusCode() int

GetStatusCode get response status code

func (*Response) HasHeader

func (this *Response) HasHeader(name string) bool

HasHeader get if header exsits in response headers

func (*Response) IsTimeout

func (this *Response) IsTimeout() bool

IsTimeout get if request is timeout

Jump to

Keyboard shortcuts

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