Documentation ¶
Index ¶
- func CarrierInterceptor(carrier Carrier) gin.HandlerFunc
- func TransportInterceptor() gin.HandlerFunc
- func UrlValues(params gin.Params) url.Values
- func WithValueCallOption(ctx context.Context, cs CallSettings) context.Context
- func WithValueCarrier(ctx context.Context, c Carrier) context.Context
- func WithValueUri(req *http.Request, params gin.Params) *http.Requestdeprecated
- type CallOption
- type CallSettings
- type Carrier
- type Client
- func (c *Client) CallSetting(path string, cos ...CallOption) *CallSettings
- func (c *Client) Delete(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Deref() *resty.Client
- func (c *Client) EncodeQuery(v any) (string, error)
- func (c *Client) EncodeURL(pathTemplate string, msg any, needQuery bool) string
- func (c *Client) Execute(ctx context.Context, method, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Get(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Head(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Invoke(ctx context.Context, method, path string, in, out any, settings *CallSettings) error
- func (c *Client) Options(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Patch(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Post(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- func (c *Client) Put(ctx context.Context, path string, req, resp any, opts ...CallOption) error
- type ClientOption
- type ErrorReply
- type Transport
- func (tr *Transport) ClientIp() string
- func (tr *Transport) FullPath() string
- func (tr *Transport) GinContext() *gin.Context
- func (tr *Transport) Kind() transport.Kind
- func (tr *Transport) Method() string
- func (tr *Transport) RequestHeader() transport.Header
- func (tr *Transport) ResponseHeader() transport.Header
- func (tr *Transport) Route() string
- type Transporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CarrierInterceptor ¶ added in v0.5.0
func CarrierInterceptor(carrier Carrier) gin.HandlerFunc
CarrierInterceptor carrier middleware.
func TransportInterceptor ¶
func TransportInterceptor() gin.HandlerFunc
TransportInterceptor transport middleware
func WithValueCallOption ¶ added in v0.4.4
func WithValueCallOption(ctx context.Context, cs CallSettings) context.Context
WithValueCallOption returns a new Context that carries value.
func WithValueCarrier ¶ added in v0.5.0
WithValueCarrier returns the value associated with ctxCarrierKey is Carrier.
Types ¶
type CallOption ¶ added in v0.4.4
type CallOption func(cs *CallSettings)
CallOption is an option used by Invoke to control behaviors of RPC calls. CallOption works by modifying relevant fields of CallSettings.
func WithCoAccept ¶ added in v0.8.0
func WithCoAccept(accept string) CallOption
WithCoAccept use encoding.MIMExxx
func WithCoContentType ¶ added in v0.4.4
func WithCoContentType(contentType string) CallOption
WithCoContentType use encoding.MIMExxx
type CallSettings ¶ added in v0.4.4
type CallSettings struct { // Path overwrite api call Path string // contains filtered or unexported fields }
CallSettings allow fine-grained control over how calls are made.
func DefaultCallOption
deprecated
added in
v0.4.4
func DefaultCallOption(path string, opts ...CallOption) CallSettings
Deprecated: use Client.CallSetting(path string, opts ...CallOption) instead.
func FromValueCallOption ¶ added in v0.4.4
func FromValueCallOption(ctx context.Context) (cs CallSettings, ok bool)
FromValueCallOption returns the CallSettings value stored in ctx, if any.
func MustFromValueCallOption ¶ added in v0.4.4
func MustFromValueCallOption(ctx context.Context) CallSettings
MustFromValueCallOption returns the CallSettings value stored in ctx.
type Carrier ¶ added in v0.5.0
type Carrier interface { // WithValueUri sets the URL params for the given request. // // Deprecated: Use BindURI not need this. WithValueUri(*http.Request, gin.Params) *http.Request // Bind checks the Method and Content-Type to select codec.Marshaler automatically, // Depending on the "Content-Type" header different bind are used. Bind(*gin.Context, any) error // BindQuery binds the passed struct pointer using the query codec.Marshaler. BindQuery(*gin.Context, any) error // BindUri binds the passed struct pointer using the uri codec.Marshaler. BindUri(*gin.Context, any) error // Error encode error response. Error(*gin.Context, error) // Render encode response. Render(*gin.Context, any) // Validate the request. Validate(context.Context, any) error }
Carrier is an HTTP Carrier.
func FromCarrier ¶ added in v0.5.0
FromCarrier returns the Carrier value stored in ctx, if not exist cause panic.
type Client ¶ added in v0.4.4
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v0.4.4
func NewClient(opts ...ClientOption) *Client
func (*Client) CallSetting ¶ added in v0.8.0
func (c *Client) CallSetting(path string, cos ...CallOption) *CallSettings
func (*Client) Delete ¶ added in v0.4.5
Delete method does DELETE HTTP request. It's defined in section 4.3.5 of RFC7231.
func (*Client) EncodeQuery ¶ added in v0.4.4
EncodeQuery encode v into “URL encoded” form ("bar=baz&foo=quux") sorted by key.
func (*Client) EncodeURL ¶ added in v0.4.4
EncodeURL encode msg to url path. pathTemplate is a template of url path like http://helloworld.dev/{name}/sub/{sub.name}.
func (*Client) Get ¶ added in v0.4.5
Get method does GET HTTP request. It's defined in section 4.3.1 of RFC7231.
func (*Client) Head ¶ added in v0.4.5
Head method does HEAD HTTP request. It's defined in section 4.3.2 of RFC7231.
func (*Client) Invoke ¶ added in v0.4.4
func (c *Client) Invoke(ctx context.Context, method, path string, in, out any, settings *CallSettings) error
Invoke the request NOTE: Do not use this function. use Execute instead.
func (*Client) Options ¶ added in v0.4.5
Options method does OPTIONS HTTP request. It's defined in section 4.3.7 of RFC7231.
func (*Client) Patch ¶ added in v0.4.5
Patch method does PATCH HTTP request. It's defined in section 2 of RFC5789.
type ClientOption ¶ added in v0.4.4
type ClientOption func(*Client)
func WithCallOption ¶ added in v0.8.0
func WithCallOption(cs ...CallOption) ClientOption
func WithEncoding ¶ added in v0.4.4
func WithEncoding(codec *encoding.Encoding) ClientOption
func WithNoAuth
deprecated
added in
v0.4.4
func WithNoAuth() ClientOption
Deprecated: use WithCallOption(WithCoNoAuth) instead.
func WithTokenSource ¶ added in v0.4.4
func WithTokenSource(t oauth2.TokenSource) ClientOption
func WithValidate ¶ added in v0.4.4
func WithValidate(f func(any) error) ClientOption
type ErrorReply ¶ added in v0.4.4
func (*ErrorReply) Error ¶ added in v0.4.4
func (e *ErrorReply) Error() string
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an HTTP transport.
func (*Transport) GinContext ¶
GinContext Service gin context
func (*Transport) RequestHeader ¶
RequestHeader return transport request header http: http.Header grpc: metadata.MD
func (*Transport) ResponseHeader ¶
ResponseHeader return transport response header http: http.Header grpc: metadata.MD
type Transporter ¶
type Transporter interface { transport.Transporter Method() string Route() string GinContext() *gin.Context }
Transporter is http Transporter