http

package
v0.0.0-...-28c4e55 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(url string, args map[string]string) (result string, err error)

Get send get request.

func Post

func Post(url, contentType string, args map[string]string) (result string, err error)

Post send post request.

Types

type Client

type Client struct {
	Header *Header
	// contains filtered or unexported fields
}

Client Http客户端

func NewClient

func NewClient() *Client

NewClient 创建HttpClient

func NewHeaderClient

func NewHeaderClient(header *Header) *Client

NewHeaderClient 创建HttpClient

func (*Client) Do

func (h *Client) Do(req *http.Request) (response *http.Response, err error)

Do 发送

func (*Client) Get

func (h *Client) Get(url string, values url.Values) (body []byte, statusCode int, err error)

Get send get request.

func (*Client) Post

func (h *Client) Post(url string, values url.Values) (body []byte, statusCode int, err error)

Post send post request.

func (*Client) PostData

func (h *Client) PostData(url string, values []byte) (body []byte, statusCode int, err error)

PostData send post request.

func (*Client) PostJSON

func (h *Client) PostJSON(url string, jsonObject interface{}) (body []byte, statusCode int, err error)

PostJSON send post request.

func (*Client) SetHeader

func (h *Client) SetHeader(header *Header)

SetHeader 设置 http request header

func (*Client) SetTimeout

func (h *Client) SetTimeout(timeout time.Duration)

SetTimeout 设置超时

func (*Client) SetTransport

func (h *Client) SetTransport(transport http.RoundTripper)

SetTransport 设置Transport

type Header map[string]string

Header Http 请求 头

func (Header) Get

func (h Header) Get(key string) string

Get 获取值

func (Header) Set

func (h Header) Set(key, value string)

Set 设置值

Jump to

Keyboard shortcuts

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