clients

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPClient = NewHTTPClient()

DefaultHTTPClient 默认的公共http客户端 建议没有特殊需求的功能都使用这个客户端

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient struct {
	http.Client
	Header http.Header
}

HTTPClient 支持socks或者http代理的,以及cookie的http客户端

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient 创建新的 http client 客户端

func (*HTTPClient) Get

func (c *HTTPClient) Get(url string) (*http.Response, error)

Get 增强http.Client.Get方法

func (*HTTPClient) Head

func (c *HTTPClient) Head(url string) (*http.Response, error)

Head 增强http.Client.Head方法

func (*HTTPClient) NewRequest

func (c *HTTPClient) NewRequest(method, url string, body io.Reader) (*http.Request, error)

NewRequest 使用客户端创建http请求

func (*HTTPClient) Post

func (c *HTTPClient) Post(url string, contentType string, body io.Reader) (*http.Response, error)

Post 增强http.Client.Post方法

func (*HTTPClient) PostForm

func (c *HTTPClient) PostForm(url string, data url.Values) (*http.Response, error)

PostForm 增强http.Client.PostForm方法

type WSClient

type WSClient struct {
	Name      string
	OnMessage func([]byte)
	OnError   func(error)
	OnConnect func(*WSClient)
	Filter    func([]byte) bool
	// contains filtered or unexported fields
}

WSClient 拓展的websocket客户端,可以自动重连 这个没有默认的客户端

func (*WSClient) Dial

func (c *WSClient) Dial(url string, headers http.Header) error

Dial 设置和远程服务器链接

func (*WSClient) IsConnected

func (c *WSClient) IsConnected() bool

IsConnected 检查是否在连接状态

func (*WSClient) Send

func (c *WSClient) Send(msgType int, msg []byte) error

Send 发送消息

Jump to

Keyboard shortcuts

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