Documentation
¶
Index ¶
- func GetAccessToken(param *GetAccessTokenParam) (string, error)
- type BaseTkApiRequest
- type BaseTkApiResponse
- type CreateTokenData
- type CreateTokenParam
- type CreateTokenRequest
- type CreateTokenResponse
- type GetAccessTokenParam
- type TkApiClient
- type TkApiRequest
- type TkConfig
- type TkHttpClient
- type TkHttpRequest
- type TkHttpResponse
- type TkOption
- func WithAppId(appId string) TkOption
- func WithAppSecret(appSecret string) TkOption
- func WithDialKeepAlive(dialKeepAlive time.Duration) TkOption
- func WithDialTimeout(dialTimeout time.Duration) TkOption
- func WithDisableKeepAlives(disableKeepAlives bool) TkOption
- func WithHeaders(headers map[string]string) TkOption
- func WithHttpReadTimeout(timeout int64) TkOption
- func WithIdleConnTimeout(idleConnTimeout time.Duration) TkOption
- func WithInsecureSkipVerify(insecureSkipVerify bool) TkOption
- func WithMaxIdleCons(maxIdleCons int) TkOption
- func WithMaxIdleConsPerHost(maxIdleConsPerHost int) TkOption
- func WithOpenRequestUrl(url string) TkOption
- func WithResponseHeaderTimeout(responseHeaderTimeout time.Duration) TkOption
- func WithSignFunc(funcName func(params map[string]any, appSecret string) string) TkOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAccessToken ¶
func GetAccessToken(param *GetAccessTokenParam) (string, error)
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
Types ¶
type BaseTkApiRequest ¶
type BaseTkApiRequest struct {
// contains filtered or unexported fields
}
func (*BaseTkApiRequest) GetClient ¶
func (r *BaseTkApiRequest) GetClient() *TkApiClient
func (*BaseTkApiRequest) GetConfig ¶
func (r *BaseTkApiRequest) GetConfig() *TkConfig
func (*BaseTkApiRequest) SetClient ¶
func (r *BaseTkApiRequest) SetClient(client *TkApiClient)
func (*BaseTkApiRequest) SetConfig ¶
func (r *BaseTkApiRequest) SetConfig(config *TkConfig)
type BaseTkApiResponse ¶
type CreateTokenData ¶
type CreateTokenData struct {
Token string `json:"token"`
}
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
type CreateTokenParam ¶
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
type CreateTokenRequest ¶
type CreateTokenRequest struct {
BaseTkApiRequest
// contains filtered or unexported fields
}
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
func NewCreateTokenRequest ¶
func NewCreateTokenRequest() *CreateTokenRequest
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
func (*CreateTokenRequest) Execute ¶
func (r *CreateTokenRequest) Execute(accessToken string) (*CreateTokenResponse, error)
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
func (*CreateTokenRequest) GetParamObject ¶
func (r *CreateTokenRequest) GetParamObject() interface{}
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
func (*CreateTokenRequest) GetParams ¶
func (r *CreateTokenRequest) GetParams() *CreateTokenParam
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
func (*CreateTokenRequest) GetUrlPath ¶
func (r *CreateTokenRequest) GetUrlPath() string
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
type CreateTokenResponse ¶
type CreateTokenResponse struct {
BaseTkApiResponse
Data CreateTokenData `json:"data"`
}
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
type GetAccessTokenParam ¶
GetAccessTokenParam 已废弃,使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam Deprecated: 使用 github.com/18721889353/sunshine/pkg/sdk/tk/api/auth/request 包中的 GetAccessTokenParam
type TkApiClient ¶
type TkApiClient struct{}
var DefaultTkApiClient *TkApiClient = NewTkApiClient()
func NewTkApiClient ¶
func NewTkApiClient() *TkApiClient
func (*TkApiClient) Request ¶
func (client *TkApiClient) Request(request TkApiRequest, accessToken string) (string, error)
func (*TkApiClient) RequestWithContext ¶
func (client *TkApiClient) RequestWithContext(ctx context.Context, request TkApiRequest, accessToken string) (string, error)
type TkApiRequest ¶
type TkConfig ¶
type TkConfig struct {
AppId string
AppSecret string
HttpReadTimeout int64
OpenRequestUrl string
Headers map[string]string
// 添加HTTP客户端配置字段
InsecureSkipVerify bool // 是否跳过SSL证书验证,true表示跳过验证(不安全),false表示验证证书
DisableKeepAlives bool // 是否禁用HTTP Keep-Alive连接复用,true表示禁用,false表示启用连接复用
MaxIdleCons int // HTTP客户端连接池中最大空闲连接数
MaxIdleConsPerHost int // 每个目标主机的最大空闲连接数
IdleConnTimeout time.Duration // 空闲连接的超时时间,超过该时间未使用的连接将被关闭
ResponseHeaderTimeout time.Duration // 从请求发送到接收到响应头的超时时间
DialTimeout time.Duration // 建立TCP连接的超时时间
DialKeepAlive time.Duration // TCP连接的Keep-Alive探测时间间隔
SignFunc func(params map[string]any, appSecret string) string
}
func NewTkConfig ¶
type TkHttpClient ¶ added in v1.3.11
type TkHttpClient struct {
// contains filtered or unexported fields
}
func GetHttpClient ¶ added in v1.3.11
func GetHttpClient() *TkHttpClient
func (*TkHttpClient) Post ¶ added in v1.3.11
func (client *TkHttpClient) Post(httpRequest *TkHttpRequest) (*TkHttpResponse, error)
func (*TkHttpClient) PostWithContext ¶ added in v1.3.11
func (client *TkHttpClient) PostWithContext(ctx context.Context, httpRequest *TkHttpRequest) (*TkHttpResponse, error)
type TkHttpRequest ¶ added in v1.3.11
type TkHttpResponse ¶ added in v1.3.11
type TkHttpResponse struct {
Body string
}
type TkOption ¶ added in v1.3.11
type TkOption func(*TkConfig)
func WithAppSecret ¶ added in v1.3.11
WithAppSecret 设置AppSecret
func WithDialKeepAlive ¶ added in v1.3.11
WithDialKeepAlive 设置连接保持时间
func WithDialTimeout ¶ added in v1.3.11
WithDialTimeout 设置连接超时时间
func WithDisableKeepAlives ¶ added in v1.3.11
WithDisableKeepAlives 设置是否禁用Keep-Alive
func WithHeaders ¶ added in v1.3.11
WithHeaders 设置请求头
func WithHttpReadTimeout ¶ added in v1.3.11
WithHttpReadTimeout 设置HTTP读取超时时间
func WithIdleConnTimeout ¶ added in v1.3.11
WithIdleConnTimeout 设置空闲连接超时时间
func WithInsecureSkipVerify ¶ added in v1.3.11
WithInsecureSkipVerify 设置是否跳过证书验证
func WithMaxIdleCons ¶ added in v1.3.11
WithMaxIdleCons 设置最大空闲连接数
func WithMaxIdleConsPerHost ¶ added in v1.3.11
WithMaxIdleConsPerHost 设置每个主机的最大空闲连接数
func WithOpenRequestUrl ¶ added in v1.3.11
WithOpenRequestUrl 设置请求URL
func WithResponseHeaderTimeout ¶ added in v1.3.11
WithResponseHeaderTimeout 设置响应头超时时间