Documentation
¶
Index ¶
- Constants
- func GetSign(query string, body []byte, date string, uuid string, credential Credential) string
- type Credential
- type CtyunClient
- type CtyunClientConfig
- type CtyunRequest
- func (c *CtyunRequest) AddHeader(key, value string) *CtyunRequest
- func (c *CtyunRequest) AddHeaders(key string, value []string) *CtyunRequest
- func (c *CtyunRequest) AddParam(key, value string) *CtyunRequest
- func (c *CtyunRequest) AddParams(key string, value []string) *CtyunRequest
- func (c *CtyunRequest) WriteJson(data interface{}, contentType string) (*CtyunRequest, error)
- func (c *CtyunRequest) WriteString(data, contentType string) (*CtyunRequest, error)
- type CtyunRequestBuilder
- func (c CtyunRequestBuilder) Build() *CtyunRequest
- func (c *CtyunRequestBuilder) ReplaceUrl(src string, target interface{}) *CtyunRequestBuilder
- func (c *CtyunRequestBuilder) WithCredential(credential Credential) *CtyunRequestBuilder
- func (c *CtyunRequestBuilder) WithEndpointName(endpointName EndpointName) *CtyunRequestBuilder
- type CtyunRequestTemplate
- type CtyunResponse
- type Endpoint
- type EndpointName
- type EndpointRegistry
- type HttpHook
- type PrintLogHttpHook
Constants ¶
View Source
const (
CtyunEndpointName = "ctyunEndpointName"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Credential ¶
type Credential struct {
// contains filtered or unexported fields
}
type CtyunClient ¶
type CtyunClient struct { Config *CtyunClientConfig // contains filtered or unexported fields }
func (*CtyunClient) RegisterEndpoint ¶
func (c *CtyunClient) RegisterEndpoint(endpoint Endpoint)
RegisterEndpoint 注册端点
func (CtyunClient) RequestToEndpoint ¶
func (c CtyunClient) RequestToEndpoint(ctx context.Context, request *CtyunRequest) (*CtyunResponse, error)
RequestToEndpoint 向端点发送请求
type CtyunClientConfig ¶
CtyunClientConfig 自定义配置
func ClientConfigForProd ¶
func ClientConfigForProd() *CtyunClientConfig
ClientConfigForProd 构建生产环境默认的客户端
func ClientConfigForTest ¶
func ClientConfigForTest() *CtyunClientConfig
ClientConfigForTest 构建测试环境默认的客户端
type CtyunRequest ¶
type CtyunRequest struct {
// contains filtered or unexported fields
}
func (*CtyunRequest) AddHeader ¶
func (c *CtyunRequest) AddHeader(key, value string) *CtyunRequest
AddHeader 增加请求头
func (*CtyunRequest) AddHeaders ¶
func (c *CtyunRequest) AddHeaders(key string, value []string) *CtyunRequest
func (*CtyunRequest) AddParam ¶
func (c *CtyunRequest) AddParam(key, value string) *CtyunRequest
AddParam 增加参数
func (*CtyunRequest) AddParams ¶
func (c *CtyunRequest) AddParams(key string, value []string) *CtyunRequest
AddParams 增加参数
func (*CtyunRequest) WriteJson ¶
func (c *CtyunRequest) WriteJson(data interface{}, contentType string) (*CtyunRequest, error)
WriteJson 以application/json方式写入
func (*CtyunRequest) WriteString ¶
func (c *CtyunRequest) WriteString(data, contentType string) (*CtyunRequest, error)
type CtyunRequestBuilder ¶
type CtyunRequestBuilder struct { EndpointName EndpointName // 终端名称 Method string // 请求方法 UrlPath string // url路径 Credential Credential // 用户信息 ContentType string // 请求类型 }
func NewCtyunRequestBuilder ¶
func NewCtyunRequestBuilder(template CtyunRequestTemplate) *CtyunRequestBuilder
func (*CtyunRequestBuilder) ReplaceUrl ¶
func (c *CtyunRequestBuilder) ReplaceUrl(src string, target interface{}) *CtyunRequestBuilder
ReplaceUrl 替换路径中的目标值,例如把/orders/{masterOrderId}替换为/orders/1
func (*CtyunRequestBuilder) WithCredential ¶
func (c *CtyunRequestBuilder) WithCredential(credential Credential) *CtyunRequestBuilder
WithCredential 增加请求credential
func (*CtyunRequestBuilder) WithEndpointName ¶
func (c *CtyunRequestBuilder) WithEndpointName(endpointName EndpointName) *CtyunRequestBuilder
WithEndpointName 增加请求终端名称
type CtyunRequestTemplate ¶
type CtyunRequestTemplate struct { EndpointName EndpointName // 终端名称 Method string // 请求方法 UrlPath string // url路径 ContentType string }
type CtyunResponse ¶
type Endpoint ¶
type Endpoint struct { Name EndpointName // 端点的名称 Url string // 对应的地址 }
type EndpointName ¶
type EndpointName string
type EndpointRegistry ¶
type EndpointRegistry struct {
// contains filtered or unexported fields
}
func DefaultEndpointRegistry ¶
func DefaultEndpointRegistry() *EndpointRegistry
DefaultEndpointRegistry 由默认的url创建
func (EndpointRegistry) GetEndpointUrl ¶
func (e EndpointRegistry) GetEndpointUrl(endpointName EndpointName) string
GetEndpointUrl 获取端点信息
func (*EndpointRegistry) Register ¶
func (e *EndpointRegistry) Register(endpoint Endpoint) error
Register 注册端点
func (*EndpointRegistry) SetDefaultUrl ¶
func (e *EndpointRegistry) SetDefaultUrl(defaultUrl string)
SetDefaultUrl 设置默认的url
type PrintLogHttpHook ¶
type PrintLogHttpHook struct{}
func (PrintLogHttpHook) AfterResponse ¶
func (d PrintLogHttpHook) AfterResponse(_ context.Context, response *http.Response)
func (PrintLogHttpHook) BeforeRequest ¶
func (d PrintLogHttpHook) BeforeRequest(_ context.Context, request *http.Request)
Click to show internal directories.
Click to hide internal directories.