core

package
v1.4.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

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 BaseTkApiResponse struct {
	Code int64  `json:"code"`
	Msg  string `json:"msg"`
}

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

type CreateTokenParam struct {
	AppId     string `json:"app_id"`
	AppSecret string `json:"app_secret"`
}

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

type GetAccessTokenParam struct {
	Config    *TkConfig
	AppId     string
	AppSecret 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 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 TkApiRequest interface {
	GetConfig() *TkConfig
	SetConfig(config *TkConfig)
	GetParamObject() interface{}
	GetUrlPath() string
}

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 GetTkConfig added in v1.3.11

func GetTkConfig() *TkConfig

GetTkConfig 获取全局配置实例(线程安全的单例模式)

func NewTkConfig

func NewTkConfig(opts ...TkOption) *TkConfig

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 TkHttpRequest struct {
	Url     string
	Params  map[string]string
	Headers map[string]string
	Body    string
}

type TkHttpResponse added in v1.3.11

type TkHttpResponse struct {
	Body string
}

type TkOption added in v1.3.11

type TkOption func(*TkConfig)

func WithAppId added in v1.3.11

func WithAppId(appId string) TkOption

WithAppId 设置AppId

func WithAppSecret added in v1.3.11

func WithAppSecret(appSecret string) TkOption

WithAppSecret 设置AppSecret

func WithDialKeepAlive added in v1.3.11

func WithDialKeepAlive(dialKeepAlive time.Duration) TkOption

WithDialKeepAlive 设置连接保持时间

func WithDialTimeout added in v1.3.11

func WithDialTimeout(dialTimeout time.Duration) TkOption

WithDialTimeout 设置连接超时时间

func WithDisableKeepAlives added in v1.3.11

func WithDisableKeepAlives(disableKeepAlives bool) TkOption

WithDisableKeepAlives 设置是否禁用Keep-Alive

func WithHeaders added in v1.3.11

func WithHeaders(headers map[string]string) TkOption

WithHeaders 设置请求头

func WithHttpReadTimeout added in v1.3.11

func WithHttpReadTimeout(timeout int64) TkOption

WithHttpReadTimeout 设置HTTP读取超时时间

func WithIdleConnTimeout added in v1.3.11

func WithIdleConnTimeout(idleConnTimeout time.Duration) TkOption

WithIdleConnTimeout 设置空闲连接超时时间

func WithInsecureSkipVerify added in v1.3.11

func WithInsecureSkipVerify(insecureSkipVerify bool) TkOption

WithInsecureSkipVerify 设置是否跳过证书验证

func WithMaxIdleCons added in v1.3.11

func WithMaxIdleCons(maxIdleCons int) TkOption

WithMaxIdleCons 设置最大空闲连接数

func WithMaxIdleConsPerHost added in v1.3.11

func WithMaxIdleConsPerHost(maxIdleConsPerHost int) TkOption

WithMaxIdleConsPerHost 设置每个主机的最大空闲连接数

func WithOpenRequestUrl added in v1.3.11

func WithOpenRequestUrl(url string) TkOption

WithOpenRequestUrl 设置请求URL

func WithResponseHeaderTimeout added in v1.3.11

func WithResponseHeaderTimeout(responseHeaderTimeout time.Duration) TkOption

WithResponseHeaderTimeout 设置响应头超时时间

func WithSignFunc added in v1.3.11

func WithSignFunc(funcName func(params map[string]any, appSecret string) string) TkOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL