Documentation ¶
Index ¶
- Variables
- type BaseMiddleware
- type Client
- func (c *Client) Call(contract giraffe.Contract, req *http.Request, opts ...giraffe.CallOption) (*http.Response, error)
- func (c *Client) Invoke(ctx context.Context, md *giraffe.MethodDesc, in interface{}, out interface{}, ...) error
- func (c *Client) NewStream(context.Context, *giraffe.StreamDesc, ...giraffe.CallOption) (giraffe.ClientStream, error)
- type ClientOption
- type Marshaler
- type Middleware
- type RPCRetryConfig
- type RetryConfig
- type StaticAddress
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultMiddleware = &BaseMiddleware{}
DefaultMiddleware 默认中间件
Functions ¶
This section is empty.
Types ¶
type BaseMiddleware ¶ added in v0.6.0
type BaseMiddleware struct { Marshaler Marshaler Unmarshaler Unmarshaler }
BaseMiddleware 基础中间件
func (*BaseMiddleware) NewRequest ¶ added in v0.6.0
func (m *BaseMiddleware) NewRequest(rule giraffe.HttpRule, in interface{}) (*http.Request, error)
NewRequest 创建 http.Request 方法
func (*BaseMiddleware) ParseResponse ¶ added in v0.6.0
func (m *BaseMiddleware) ParseResponse(rule giraffe.HttpRule, resp *http.Response, out interface{}) error
ParseResponse 解析 http.Response 方法
type Client ¶
type Client struct { *http.Client Middleware Middleware NameService giraffe.NameService Scheme string // contains filtered or unexported fields }
Client REST Client对象
func (*Client) Call ¶
func (c *Client) Call(contract giraffe.Contract, req *http.Request, opts ...giraffe.CallOption) (*http.Response, error)
Call 请求函数
type ClientOption ¶ added in v0.5.2
type ClientOption func(c *Client)
ClientOption Client 配置函数
func WithClient ¶ added in v0.5.2
func WithClient(client *http.Client) ClientOption
WithClient 注入 http.Client
func WithNameService ¶ added in v0.5.2
func WithNameService(n giraffe.NameService) ClientOption
WithNameService 注入 NameService
func WithRetryConfig ¶ added in v1.0.1
func WithRetryConfig(conf RetryConfig) ClientOption
func WithScheme ¶ added in v1.0.5
func WithScheme(scheme string) ClientOption
type Middleware ¶
type Middleware interface { NewRequest(rule giraffe.HttpRule, in interface{}) (*http.Request, error) ParseResponse(rule giraffe.HttpRule, resp *http.Response, out interface{}) error }
Middleware 中间件定义
type RPCRetryConfig ¶ added in v1.0.1
type RPCRetryConfig map[string]RetryConfig
type RetryConfig ¶ added in v1.0.1
type StaticAddress ¶
type StaticAddress string
func (StaticAddress) GetAddress ¶
func (s StaticAddress) GetAddress(ctx context.Context, contract giraffe.Contract) (string, error)
func (StaticAddress) GetAllAddresses ¶
func (s StaticAddress) GetAllAddresses(ctx context.Context, contract giraffe.Contract) ([]string, error)
Click to show internal directories.
Click to hide internal directories.