apiutils

package
v0.0.0-...-ba5a92e Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: AGPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppInfoDefaultGetter = func(ctx echo.Context, cond db.Compound) (appInfo AppInfo, err error) {
	err = ctx.NewError(code.Unsupported, `尚未设置App信息获取方式`)
	return
}
View Source
var OauthOptionsCreater = func(ctx echo.Context, typ Type, generators ...sdk_options.URLValuesGenerator) OauthOption {
	return NewOptions(ctx, TypeOauth, generators...)
}

Functions

func Decrypt

func Decrypt(decrypted string, secret string) string

func Encrypt

func Encrypt(raw string, secret string) string

func GetOauthProviderTitle

func GetOauthProviderTitle(list []*OauthProvider, name string) string

Types

type AppInfo

type AppInfo interface {
	GetAppSecret() string
	GetAppId() string
	IsOfficial() bool
}

type AppInfoFromAccount

type AppInfoFromAccount struct {
	Account   *dbschema.OfficialCommonApiAccount
	URLPrefix string
}

func (AppInfoFromAccount) GetApiEndpoint

func (a AppInfoFromAccount) GetApiEndpoint() string

func (AppInfoFromAccount) GetAppID

func (a AppInfoFromAccount) GetAppID() string

func (AppInfoFromAccount) GetAppSecret

func (a AppInfoFromAccount) GetAppSecret() string

type AppInfoFromOpenApp

type AppInfoFromOpenApp struct {
	App       AppInfo
	URLPrefix string
}

func (AppInfoFromOpenApp) GetApiEndpoint

func (a AppInfoFromOpenApp) GetApiEndpoint() string

func (AppInfoFromOpenApp) GetAppID

func (a AppInfoFromOpenApp) GetAppID() string

func (AppInfoFromOpenApp) GetAppSecret

func (a AppInfoFromOpenApp) GetAppSecret() string

type OauthOption

type OauthOption interface {
	GetAccountID() uint64
	ApplySetting() (err error)
	GetAppID() string
	OauthProvierListURL() (string, error)
}

type OauthProvider

type OauthProvider struct {
	Name      string `json:"name" xml:"name"`
	English   string `json:"english" xml:"english"`
	IconClass string `json:"iconClass" xml:"iconClass"`
	IconImage string `json:"iconImage" xml:"iconImage"`
	WrapClass string `json:"wrapClass" xml:"wrapClass"`
	LoginURL  string `json:"loginURL" xml:"loginURL"`
}

func GetOauthProvider

func GetOauthProvider(list []*OauthProvider, name string) *OauthProvider

func OauthProviders

func OauthProviders(ctx echo.Context) ([]*OauthProvider, error)

func OauthProvidersFrom

func OauthProvidersFrom(accounts []oauth2.Account) []*OauthProvider

type OauthProvidersResponse

type OauthProvidersResponse struct {
	List []*OauthProvider `json:"list"`
}

type Options

type Options struct {
	*sdk_options.Options
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(ctx echo.Context, typ Type, generators ...sdk_options.URLValuesGenerator) *Options

func (*Options) ApplySetting

func (o *Options) ApplySetting() (err error)

func (*Options) Context

func (o *Options) Context() echo.Context

func (*Options) GetAccountID

func (o *Options) GetAccountID() uint64

func (*Options) SetAppInfoGetter

func (o *Options) SetAppInfoGetter(appInfoGetter func(ctx echo.Context, cond db.Cond) (appInfo AppInfo, err error)) *Options

type Type

type Type = sdk_options.Type
const (
	// TypeOauth 社区登录类型
	TypeOauth Type = sdk_options.TypeOauth
	// TypePayment 支付类型
	TypePayment Type = sdk_options.TypePayment
)

Jump to

Keyboard shortcuts

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