apiserver

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeWebServer

func InitializeWebServer(config *Config) (server.Server, error)

func InstallGenericAPI

func InstallGenericAPI(engine *gin.Engine)

InstallGenericAPI 注册业务无关的路由,例如 pprof、404 处理等.

func NewWebServer

func NewWebServer(serverMode string, serverConfig *ServerConfig) (server.Server, error)

func ProvideDB

func ProvideDB(cfg *Config) (*gorm.DB, error)

ProvideDB 根据配置提供一个数据库实例。

Types

type Config

type Config struct {
	ServerMode        string
	JWTKey            string
	Expiration        time.Duration
	EnableMemoryStore bool
	HTTPOptions       *genericoptions.HTTPOptions
	TLSOptions        *genericoptions.TLSOptions
	MySQLOptions      *genericoptions.MySQLOptions
}

func (*Config) NewDB

func (cfg *Config) NewDB() (*gorm.DB, error)

NewDB 创建一个 *gorm.DB 实例.

func (*Config) NewUnionServer

func (cfg *Config) NewUnionServer() (*UnionServer, error)

type ServerConfig

type ServerConfig struct {
	// contains filtered or unexported fields
}

func (*ServerConfig) InstallRESTAPI

func (c *ServerConfig) InstallRESTAPI(engine *gin.Engine)

注册 API 路由。路由的路径和 HTTP 方法,严格遵循 REST 规范.

func (*ServerConfig) NewGinServer

func (c *ServerConfig) NewGinServer() server.Server

NewGinServer 初始化一个新的 Gin 服务器实例.

type UnionServer

type UnionServer struct {
	// contains filtered or unexported fields
}

func (*UnionServer) Run

func (s *UnionServer) Run() error

type UserRetriever

type UserRetriever struct {
	// contains filtered or unexported fields
}

UserRetriever 定义一个用户数据获取器. 用来获取用户信息.

func (*UserRetriever) GetUser

func (r *UserRetriever) GetUser(ctx context.Context, userID string) (*model.UserM, error)

GetUser 根据用户 ID 获取用户信息.

Directories

Path Synopsis
biz
pkg
nolint: dupl
nolint: dupl

Jump to

Keyboard shortcuts

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