Versions in this module Expand all Collapse all v1 v1.2.0 Sep 26, 2025 Changes in this version + const AkLen + const EnvironmentDev + const EnvironmentProd + const EnvironmentTest + const OccurOccasionAfterResponse + const OccurOccasionBeforeRequest + const OccurOccasionBeforeResponse + const SkLen + const StatusCodeSuccessString + var Environments = []Environment + func CheckAk(ak string) error + func CheckSk(sk string) error + func ClientProd() *http.Client + func ClientTest() *http.Client + func GetSign(query string, body []byte, tim time.Time, uuid string, credential Credential) string + type AddUserAgentHttpHook struct + func (h AddUserAgentHttpHook) AfterResponse(_ context.Context, _ *http.Response) + func (h AddUserAgentHttpHook) BeforeRequest(_ context.Context, request *http.Request) + type ApiDecoratorChain struct + Hooks []ApiHook + Target interface{} + func (this ApiDecoratorChain) Next(ctx context.Context, credential *Credential, param interface{}) (interface{}, CtyunRequestError) + type ApiHandler interface + Do func(context.Context, *Credential, interface{}) (interface{}, CtyunRequestError) + func Wrap(target ApiHandler, builder ApiHookBuilder) ApiHandler + type ApiHook func(context.Context, *Credential, interface{}, ApiDecoratorChain) (interface{}, CtyunRequestError) + type ApiHookBuilder struct + func NewApiHookBuilder() *ApiHookBuilder + func (this *ApiHookBuilder) AddHooks(hook ApiHook) *ApiHookBuilder + type Credential struct + func NewCredential(ak string, sk string) (*Credential, error) + func NewCredentialFromEnv() (*Credential, error) + type CtyunClient struct + Config *CtyunClientConfig + Env Environment + func EnvOf(env Environment) *CtyunClient + func NewCtyunClient(env Environment, cfg *CtyunClientConfig) (*CtyunClient, error) + func (c *CtyunClient) RegisterEndpoint(env Environment, endpoint Endpoint) + func (c CtyunClient) RequestToEndpoint(ctx context.Context, endpointName EndpointName, request *CtyunRequest) (*CtyunResponse, CtyunRequestError) + type CtyunClientConfig struct + ApiHooks []ApiHook + Client *http.Client + HttpHooks []HttpHook + func ClientConfigProd() *CtyunClientConfig + func ClientConfigTest() *CtyunClientConfig + type CtyunRequest struct + func (c *CtyunRequest) AddHeader(key, value string) *CtyunRequest + func (c *CtyunRequest) AddParam(key, value string) *CtyunRequest + func (c *CtyunRequest) WriteJson(data interface{}) (*CtyunRequest, CtyunRequestError) + func (c *CtyunRequest) WriteXWwwFormUrlEncoded(data url.Values) *CtyunRequest + type CtyunRequestBuilder struct + Method string + UrlPath string + func (c CtyunRequestBuilder) WithCredential(credential *Credential) *CtyunRequest + type CtyunRequestError interface + CtyunResponse func() *CtyunResponse + ErrorCode func() string + OccurOccasion func() OccurOccasion + func ConsoleLogApiHook(ctx context.Context, credential *Credential, param interface{}, ...) (interface{}, CtyunRequestError) + func ErrorAfterResponse(err error, resp *CtyunResponse) CtyunRequestError + func ErrorBeforeRequest(err error) CtyunRequestError + func ErrorBeforeResponse(err error) CtyunRequestError + func WrapError(err error, resp *CtyunResponse) CtyunRequestError + func WrapWithErrorCode(err error, errorCode string, resp *CtyunResponse) CtyunRequestError + type CtyunResponse struct + Request *http.Request + Response *http.Response + func (c CtyunResponse) Parse(obj interface{}) CtyunRequestError + func (c CtyunResponse) ParseByStandardModel(obj interface{}) (*CtyunResponseModel, CtyunRequestError) + func (c CtyunResponse) ParseByStandardModelWithCheck(obj interface{}) CtyunRequestError + type CtyunResponseModel struct + Description string + ErrorCode interface{} + ErrorMsg string + Message string + ReturnObj interface{} + StatusCode interface{} + func (c CtyunResponseModel) IsSuccess() bool + func (c CtyunResponseModel) ParseErrorCode() string + func (c CtyunResponseModel) ParseStatusCode() string + type Endpoint struct + EndpointName EndpointName + Url string + type EndpointName string + type EndpointRegistry map[EndpointName]Endpoint + func (e *EndpointRegistry) Register(endpoint Endpoint) error + func (e EndpointRegistry) GetEndpoint(endpointName EndpointName) (Endpoint, bool) + type Environment string + type HttpHook interface + AfterResponse func(context.Context, *http.Response) + BeforeRequest func(context.Context, *http.Request) + type OccurOccasion int + type PrintLogHttpHook struct + func (d PrintLogHttpHook) AfterResponse(_ context.Context, response *http.Response) + func (d PrintLogHttpHook) BeforeRequest(_ context.Context, request *http.Request) + type StubApiHook struct + func NewStubApiHook() *StubApiHook + func (this *StubApiHook) RegisterStubWithApiHandler(handler interface{}, f StubFunc) + func (this *StubApiHook) RegisterStubWithName(stubName string, f StubFunc) + func (this StubApiHook) Stub(ctx context.Context, credential *Credential, param interface{}, ...) (interface{}, CtyunRequestError) + type StubFunc func(ctx context.Context, credential *Credential, param interface{}, ...) (interface{}, CtyunRequestError)