Documentation ¶
Index ¶
- type APICache
- type APIConfig
- type AsyncServer
- func (c *AsyncServer) Delete(ctx *plugin.Context, url string, body interface{}, headers *map[string]string) (*Result, error)
- func (c *AsyncServer) Do(ctx *plugin.Context, method string, url string, body interface{}, ...) (*Result, error)
- func (c *AsyncServer) Get(ctx *plugin.Context, url string, headers *map[string]string) (*Result, error)
- func (c *AsyncServer) Head(ctx *plugin.Context, url string, headers *map[string]string) (*Result, error)
- func (c *AsyncServer) ManualDo(ctx *plugin.Context, method string, url string, body interface{}, ...) (*ManualResult, error)
- func (c *AsyncServer) OnStop(f func())
- func (c *AsyncServer) Open(ctx *plugin.Context, url string, headers *map[string]string) (*WS, error)
- func (c *AsyncServer) Post(ctx *plugin.Context, url string, body interface{}, headers *map[string]string) (*Result, error)
- func (c *AsyncServer) Put(ctx *plugin.Context, url string, body interface{}, headers *map[string]string) (*Result, error)
- func (c *AsyncServer) SetBaseURL(url string)
- func (c *AsyncServer) SetGlobalHeaders(headers map[string]string)
- func (c *AsyncServer) Stop()
- func (c *AsyncServer) Wait()
- type DiscoverClient
- func (c *DiscoverClient) Delete(ctx *plugin.Context, app, url string, body interface{}, ...) (*Result, error)
- func (c *DiscoverClient) Do(ctx *plugin.Context, method, app, url string, body interface{}, ...) (*Result, error)
- func (c *DiscoverClient) Get(ctx *plugin.Context, app, url string, headers *map[string]string) (*Result, error)
- func (c *DiscoverClient) Head(ctx *plugin.Context, app, url string, headers *map[string]string) (*Result, error)
- func (c *DiscoverClient) ManualDo(ctx *plugin.Context, method, app string, url string, body interface{}, ...) (*ManualResult, error)
- func (c *DiscoverClient) Open(ctx *plugin.Context, app, url string, headers *map[string]string) (*WS, error)
- func (c *DiscoverClient) Post(ctx *plugin.Context, app, url string, body interface{}, ...) (*Result, error)
- func (c *DiscoverClient) Put(ctx *plugin.Context, app, url string, body interface{}, ...) (*Result, error)
- func (c *DiscoverClient) SetGlobalHeaders(headers map[string]string)
- type ManualResult
- type ProxyByResult
- type Result
- type Session
- type WS
- func (ws *WS) Close() error
- func (ws *WS) EnableCompression()
- func (ws *WS) Read() (string, error)
- func (ws *WS) ReadBytes() ([]byte, error)
- func (ws *WS) ReadJSON() (interface{}, error)
- func (ws *WS) Write(content string) error
- func (ws *WS) WriteBytes(content []byte) error
- func (ws *WS) WriteJSON(content interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIConfig ¶
type AsyncServer ¶
type AsyncServer struct { Addr string Proto string ProtoName string // contains filtered or unexported fields }
func (*AsyncServer) Delete ¶
func (c *AsyncServer) Delete(ctx *plugin.Context, url string, body interface{}, headers *map[string]string) (*Result, error)
Delete 发送DELETE请求
func (*AsyncServer) Do ¶
func (c *AsyncServer) Do(ctx *plugin.Context, method string, url string, body interface{}, headers *map[string]string) (*Result, error)
Do 发送请求 * method 请求方法,GET、POST等
func (*AsyncServer) Get ¶
func (c *AsyncServer) Get(ctx *plugin.Context, url string, headers *map[string]string) (*Result, error)
Get 发送GET请求 * url 以http://或https://开头的URL地址,如果设置了baseURL可以只提供path部分 * headers 传入一个Key-Value对象的HTTP头信息,如果不指定头信息这个参数可以省略不传 * return 返回结果对象,如果返回值是JSON格式,将自动转化为对象否则将字符串放在.result中,如发生错误将抛出异常,返回的对象中还包括:headers、statusCode、statusMessage
func (*AsyncServer) Head ¶
func (c *AsyncServer) Head(ctx *plugin.Context, url string, headers *map[string]string) (*Result, error)
Head 发送HEAD请求
func (*AsyncServer) ManualDo ¶
func (c *AsyncServer) ManualDo(ctx *plugin.Context, method string, url string, body interface{}, headers *map[string]string) (*ManualResult, error)
ManualDo 手动处理请求,需要自行从返回结果中读取数据,可实现SSE客户端 ManualDo return 应答的对象(需手动读取数据并关闭请求)
func (*AsyncServer) OnStop ¶
func (c *AsyncServer) OnStop(f func())
func (*AsyncServer) Open ¶
func (c *AsyncServer) Open(ctx *plugin.Context, url string, headers *map[string]string) (*WS, error)
Open 打开一个Websocket连接 Open return Websocket对象(使用完毕请关闭连接)
func (*AsyncServer) Post ¶
func (c *AsyncServer) Post(ctx *plugin.Context, url string, body interface{}, headers *map[string]string) (*Result, error)
Post 发送POST请求 * body 可以传入任意类型,如果不是字符串或二进制数组时会自动添加application/json头,数据将以json格式发送
func (*AsyncServer) Put ¶
func (c *AsyncServer) Put(ctx *plugin.Context, url string, body interface{}, headers *map[string]string) (*Result, error)
Put 发送PUT请求
func (*AsyncServer) SetBaseURL ¶
func (c *AsyncServer) SetBaseURL(url string)
SetBaseURL 设置一个URL前缀,后续请求中可以只提供path部分 SetBaseURL url 以http://或https://开头的URL地址
func (*AsyncServer) SetGlobalHeaders ¶
func (c *AsyncServer) SetGlobalHeaders(headers map[string]string)
SetGlobalHeaders 设置固定的HTTP头部信息,在每个请求中都加入这些HTTP头 SetGlobalHeaders headers 传入一个Key-Value对象的HTTP头信息
func (*AsyncServer) Stop ¶
func (c *AsyncServer) Stop()
func (*AsyncServer) Wait ¶
func (c *AsyncServer) Wait()
type DiscoverClient ¶
type DiscoverClient struct {
// contains filtered or unexported fields
}
func (*DiscoverClient) Delete ¶
func (c *DiscoverClient) Delete(ctx *plugin.Context, app, url string, body interface{}, headers *map[string]string) (*Result, error)
Delete 发送DELETE请求
func (*DiscoverClient) Do ¶
func (c *DiscoverClient) Do(ctx *plugin.Context, method, app, url string, body interface{}, headers *map[string]string) (*Result, error)
Do 发送请求 * method 请求方法,GET、POST等
func (*DiscoverClient) Get ¶
func (c *DiscoverClient) Get(ctx *plugin.Context, app, url string, headers *map[string]string) (*Result, error)
Get 发送GET请求 * url 以http://或https://开头的URL地址,如果设置了baseURL可以只提供path部分 * headers 传入一个Key-Value对象的HTTP头信息,如果不指定头信息这个参数可以省略不传 * return 返回结果对象,如果返回值是JSON格式,将自动转化为对象否则将字符串放在.result中,如发生错误将抛出异常,返回的对象中还包括:headers、statusCode、statusMessage
func (*DiscoverClient) Head ¶
func (c *DiscoverClient) Head(ctx *plugin.Context, app, url string, headers *map[string]string) (*Result, error)
Head 发送HEAD请求
func (*DiscoverClient) ManualDo ¶
func (c *DiscoverClient) ManualDo(ctx *plugin.Context, method, app string, url string, body interface{}, headers *map[string]string) (*ManualResult, error)
ManualDo 手动处理请求,需要自行从返回结果中读取数据,可实现SSE客户端 ManualDo return 应答的对象(需手动读取数据并关闭请求)
func (*DiscoverClient) Open ¶
func (c *DiscoverClient) Open(ctx *plugin.Context, app, url string, headers *map[string]string) (*WS, error)
Open 打开一个Websocket连接 Open return Websocket对象(使用完毕请关闭连接)
func (*DiscoverClient) Post ¶
func (c *DiscoverClient) Post(ctx *plugin.Context, app, url string, body interface{}, headers *map[string]string) (*Result, error)
Post 发送POST请求 * body 可以传入任意类型,如果不是字符串或二进制数组时会自动添加application/json头,数据将以json格式发送
func (*DiscoverClient) Put ¶
func (c *DiscoverClient) Put(ctx *plugin.Context, app, url string, body interface{}, headers *map[string]string) (*Result, error)
Put 发送PUT请求
func (*DiscoverClient) SetGlobalHeaders ¶
func (c *DiscoverClient) SetGlobalHeaders(headers map[string]string)
SetGlobalHeaders 设置固定的HTTP头部信息,在每个请求中都加入这些HTTP头 SetGlobalHeaders headers 传入一个Key-Value对象的HTTP头信息
type ManualResult ¶
type ManualResult struct { Result // contains filtered or unexported fields }
func (*ManualResult) Close ¶
func (r *ManualResult) Close() error
func (*ManualResult) Save ¶
func (r *ManualResult) Save(filename string) error