Documentation ¶
Index ¶
- Constants
- func RegisterOnGlobalStage(plugFunc ...HandlerFunc)
- func RegisterOnRequestStage(plugFunc ...HandlerFunc)
- type Body
- type Client
- type Context
- type Func
- type HandlerFunc
- type Option
- func Breaker(config *breaker.Config) Option
- func Cluster(clu *upstream.Cluster) Option
- func DialTimeout(d time.Duration) Option
- func IdleConnTimeout(d time.Duration) Option
- func KeepAliveTimeout(d time.Duration) Option
- func KeepAlivesDisable(t bool) Option
- func Limiter(config *ratelimit.Config) Option
- func LocalName(n string) Option
- func Logger(logger log.Kit) Option
- func MaxIdleConns(d int) Option
- func MaxIdleConnsPerHost(d int) Option
- func Namespace(n string) Option
- func ProtoType(p string) Option
- func RequestTimeout(d time.Duration) Option
- func RetryTimes(d int) Option
- func ServiceName(sn string) Option
- func SlowTimeout(d time.Duration) Option
- func Tracer(tracer opentracing.Tracer) Option
- func WithClient(client *http.Client) Option
- type Options
- type Request
- func (r *Request) AddHeader(key, value string) *Request
- func (r *Request) AddQueryParam(key, value string) *Request
- func (r *Request) AddQueryParamInt(key string, value int) *Request
- func (r *Request) AddQueryParamInt64(key string, value int64) *Request
- func (r *Request) AddQueryParamUint64(key string, value uint64) *Request
- func (r *Request) Baggage(key string) string
- func (r *Request) DelHeader(key string) *Request
- func (r *Request) ForeachBaggage(handler func(key, val string) error) error
- func (r *Request) RawRequest() *http.Request
- func (r *Request) SetBaggage(key, value string)
- func (r *Request) WithBigBody(body io.Reader) *Request
- func (r *Request) WithBody(body io.Reader) *Request
- func (r *Request) WithCookie(ck *http.Cookie) *Request
- func (r *Request) WithFormData(data map[string]string) *Request
- func (r *Request) WithMethod(method string) *Request
- func (r *Request) WithMultiCookie(cks []*http.Cookie) *Request
- func (r *Request) WithMultiHeader(headers map[string]string) *Request
- func (r *Request) WithMultiQueryParam(params map[string]string) *Request
- func (r *Request) WithOption(ro *RequestOption) *Request
- func (r *Request) WithPath(path string) *Request
- func (r *Request) WithPathParams(params map[string]string) *Request
- func (r *Request) WithQueryParam(key, value string) *Request
- func (r *Request) WithQueryParamInt(key string, value int) *Request
- func (r *Request) WithQueryParamInt64(key string, value int64) *Request
- func (r *Request) WithQueryParamUint64(key string, value uint64) *Request
- func (r *Request) WithRequest(req *http.Request) *Request
- func (r *Request) WithScheme(scheme string) *Requestdeprecated
- func (r *Request) WithStruct(s interface{}) *Request
- func (r *Request) WithURL(uri string) *Request
- type RequestOption
- type Response
- func (r *Response) Body() *Body
- func (r *Response) Bytes() []byte
- func (r *Response) Code() int
- func (r *Response) Error() error
- func (r *Response) GetHeader(key string) string
- func (r *Response) JSON(obj interface{}) error
- func (r *Response) RawRequest() *http.Request
- func (r *Response) RawResponse() *http.Response
- func (r *Response) Save(fileName string) error
- func (r *Response) String() string
Constants ¶
View Source
const ( MethodGet = "GET" MethodPost = "POST" MethodPut = "PUT" MethodDelete = "DELETE" MethodPatch = "PATCH" MethodHead = "HEAD" MethodOptions = "OPTIONS" )
View Source
const ( Success = 0 ChannelBroken = 9 FailedPrecondition = 100 Canceled = 102 DeadlineExceeded = 103 ConfigLb = 104 BreakerOpen = 105 LimitedExceeded = 106 UnKnown = 1001 )
Variables ¶
This section is empty.
Functions ¶
func RegisterOnGlobalStage ¶
func RegisterOnGlobalStage(plugFunc ...HandlerFunc)
plugins will be effect always
func RegisterOnRequestStage ¶
func RegisterOnRequestStage(plugFunc ...HandlerFunc)
plugins will be effect for a http request or a http route
Types ¶
type Client ¶
type Client interface { Call(*Request) (*Response, error) Use(p ...HandlerFunc) }
client interface
var DefaultClient Client
Deprecated: DefaultClient should not use anymore.
type Context ¶
type Option ¶
type Option func(*Options)
func DialTimeout ¶
func IdleConnTimeout ¶
func KeepAliveTimeout ¶
func KeepAlivesDisable ¶
if true, do not re-use of TCP connections
func MaxIdleConns ¶
func MaxIdleConnsPerHost ¶
func RequestTimeout ¶
func RetryTimes ¶
func ServiceName ¶
func SlowTimeout ¶
func WithClient ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func (*Request) AddQueryParam ¶
func (*Request) AddQueryParamInt ¶
func (*Request) AddQueryParamInt64 ¶
func (*Request) AddQueryParamUint64 ¶
func (*Request) ForeachBaggage ¶
遍历所有已设置的用户自定义baggage信息
func (*Request) RawRequest ¶
RawRequest() build a http request, after RawRequest(), Request should not be changed by WithXXX func
func (*Request) WithFormData ¶
`application/x-www-form-urlencoded`
func (*Request) WithMethod ¶
func (*Request) WithMultiHeader ¶
func (*Request) WithMultiQueryParam ¶
func (*Request) WithOption ¶
func (r *Request) WithOption(ro *RequestOption) *Request
func (*Request) WithPathParams ¶
url params: /v1/users/:userId/:subAccountId/details
func (*Request) WithQueryParam ¶
func (*Request) WithQueryParamInt ¶
func (*Request) WithQueryParamInt64 ¶
func (*Request) WithQueryParamUint64 ¶
func (*Request) WithScheme
deprecated
func (*Request) WithStruct ¶
type RequestOption ¶
type RequestOption struct {
// contains filtered or unexported fields
}
func (*RequestOption) MetricTags ¶
func (ro *RequestOption) MetricTags(t map[string]string) *RequestOption
func (*RequestOption) RequestTimeoutMS ¶
func (ro *RequestOption) RequestTimeoutMS(timeout int) *RequestOption
func (*RequestOption) RetryTimes ¶
func (ro *RequestOption) RetryTimes(cnt int) *RequestOption
func (*RequestOption) SlowTimeoutMS ¶
func (ro *RequestOption) SlowTimeoutMS(timeout int) *RequestOption
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) RawRequest ¶
func (*Response) RawResponse ¶
Click to show internal directories.
Click to hide internal directories.