discover

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoverApp

type DiscoverApp struct {
	// contains filtered or unexported fields
}

func GetDiscoverApp

func GetDiscoverApp(app string, request *http.Request, logger *log.Logger) *DiscoverApp

GetDiscoverApp 获得一个服务发现的客户端,如果在配置(server>calls)中指定了AccessToken、超时时间或者HTTP协议(如:iZg753bnsBxTOqHjaeEdt2szvov95eLq34G6jiHBoeE=:1:s:60s)会自动在获得的客户端中设置好 GetDiscoverApp app 需要访问的服务名称 GetDiscoverApp return 服务发现客户端对象,支持的方法:get、post、put、delete、head、setGlobalHeaders

func (*DiscoverApp) Delete

func (dApp *DiscoverApp) Delete(path string, data *map[string]interface{}, headers *map[string]string) (map[string]interface{}, error)

Delete 发送DELETE请求

func (*DiscoverApp) Get

func (dApp *DiscoverApp) Get(path string, headers *map[string]string) (map[string]interface{}, error)

Get 发送GET请求 * path /开头的请求路径,调用时会自动加上负载均衡到的目标节点的URL前缀发送HTTP请求 * headers 传入一个Key-Value对象的HTTP头信息,如果不指定头信息这个参数可以省略不传 * return 返回结果对象,如果返回值是JSON格式,将自动转化为对象否则将字符串放在.result中,如发生错误将抛出异常,返回的对象中还包括:headers、statusCode、statusMessage

func (*DiscoverApp) Head

func (dApp *DiscoverApp) Head(path string, headers *map[string]string) (map[string]interface{}, error)

Head 发送HEAD请求

func (*DiscoverApp) Post

func (dApp *DiscoverApp) Post(path string, data *map[string]interface{}, headers *map[string]string) (map[string]interface{}, error)

Post 发送POST请求 * data 可以传入任意类型,如果不是字符串或二进制数组时会自动添加application/json头,数据将以json格式发送

func (*DiscoverApp) Put

func (dApp *DiscoverApp) Put(path string, data *map[string]interface{}, headers *map[string]string) (map[string]interface{}, error)

Put 发送PUT请求

func (*DiscoverApp) SetGlobalHeaders

func (dApp *DiscoverApp) SetGlobalHeaders(headers map[string]string)

SetGlobalHeaders 设置固定的HTTP头部信息,在每个请求中都加入这些HTTP头 * SetGlobalHeaders 传入一个Key-Value对象的HTTP头信息

Jump to

Keyboard shortcuts

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