Documentation ¶
Index ¶
- Constants
- func Init(client http.Client, logName string, options ...ClientOption)
- type ApiOption
- type ApiServer
- func (server *ApiServer) Get(c context.Context, uri string, dataResult interface{}, ...) (int, error)
- func (server *ApiServer) GetParams(c context.Context, uri string, params map[string]string, ...) (int, error)
- func (server *ApiServer) Post(c context.Context, uri string, dataResult interface{}, ...) (int, error)
- func (server *ApiServer) PostJSON(c context.Context, uri string, body map[string]interface{}, ...) (int, error)
- func (server *ApiServer) SimpleGet(c context.Context, uri string, result interface{}, options ...RequestOption) error
- func (server *ApiServer) SimpleGetParams(c context.Context, uri string, params map[string]string, result interface{}) error
- func (server *ApiServer) SimplePost(c context.Context, uri string, result interface{}, options ...RequestOption) error
- func (server *ApiServer) SimplePostJSON(c context.Context, uri string, body map[string]interface{}, result interface{}) error
- type ClientOption
- type IReply
- type Reply
- type Request
- type RequestOption
Constants ¶
const ( GetRequest requestMethod = "GET" PostRequest requestMethod = "POST" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiServer ¶
type ApiServer struct { Host string // contains filtered or unexported fields }
func NewApiServer ¶
func (*ApiServer) Get ¶
func (server *ApiServer) Get(c context.Context, uri string, dataResult interface{}, options ...RequestOption) (int, error)
GET请求api,解析响应数据的data字段数据 @param uri 请求uri @param dataResult 响应结果data数据绑定 @param options 请求可省参数 @return int 响应码 @return error 错误
func (*ApiServer) GetParams ¶
func (server *ApiServer) GetParams(c context.Context, uri string, params map[string]string, dataResult interface{}) (int, error)
GET请求api,解析响应数据的data字段数据 @param uri 请求uri @param params 请求参数 @param dataResult 响应结果data数据绑定 @return int 响应码 @return error 错误
func (*ApiServer) Post ¶
func (server *ApiServer) Post(c context.Context, uri string, dataResult interface{}, options ...RequestOption) (int, error)
POST请求api,解析响应数据的data字段数据 @param uri 请求uri @param dataResult 响应结果data数据绑定 @param options 请求可省参数 @return int 响应码 @return error 错误
func (*ApiServer) PostJSON ¶
func (server *ApiServer) PostJSON(c context.Context, uri string, body map[string]interface{}, dataResult interface{}) (int, error)
POST请求api,解析响应数据的data字段数据 @param uri 请求uri @param body 请求体 @param dataResult 响应结果data数据绑定 @return int 响应码 @return error 错误
func (*ApiServer) SimpleGet ¶
func (server *ApiServer) SimpleGet(c context.Context, uri string, result interface{}, options ...RequestOption) error
GET请求api,解析整个响应数据 @param uri 请求uri @param result 响应结果数据绑定 @param options 请求可省参数 @return error 错误
func (*ApiServer) SimpleGetParams ¶
func (server *ApiServer) SimpleGetParams(c context.Context, uri string, params map[string]string, result interface{}) error
GET请求api,解析整个响应数据 @param uri 请求uri @param params 请求参数 @param result 响应结果数据绑定 @return error
func (*ApiServer) SimplePost ¶
func (server *ApiServer) SimplePost(c context.Context, uri string, result interface{}, options ...RequestOption) error
POST请求api,解析整个响应数据 @param uri 请求uri @param result 响应结果数据绑定 @param options 请求可省参数 @return error
type ClientOption ¶
type ClientOption func(client *globalClient)
func WithHeaderB3TraceFromCtx ¶
func WithHeaderB3TraceFromCtx(key string) ClientOption
是否开启zipkin-B3追踪,将会在头部注入追踪数据,数据从上下文获取 key为从上下文获取b3.SpanContext数据的键名
type IReply ¶
type IReply interface { GetCode() int GetUnknownCode() int GetSuccessCode() int GetMsg() string IsSuccess() bool UnmarshalData(dataResult interface{}) error }
func DefaultReply ¶
func DefaultReply() IReply
type Reply ¶
func (*Reply) GetSuccessCode ¶
func (*Reply) GetUnknownCode ¶
func (*Reply) UnmarshalData ¶
type RequestOption ¶
type RequestOption func(request *Request)