Documentation
¶
Index ¶
- func BuildEngine(ctx context.Context, injector *wirex.Injector, opts *EngineOptions) (*gin.Engine, error)
- func ListenAndServe(ctx context.Context, handler http.Handler) (func(), error)
- func RegisterTo(ctx context.Context, e *gin.Engine, injector *wirex.Injector, ...) error
- func Run(ctx context.Context, runCfg RunConfig) error
- type CaptchaRedisStore
- type EngineOptions
- type RunConfig
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEngine ¶
func BuildEngine(ctx context.Context, injector *wirex.Injector, opts *EngineOptions) (*gin.Engine, error)
BuildEngine creates a new Gin engine with admin middlewares, routes, optional swagger/SPA.
func ListenAndServe ¶
ListenAndServe starts HTTP on config.C.General.HTTP.Addr using the given handler. Returns a shutdown function.
func RegisterTo ¶
func RegisterTo(ctx context.Context, e *gin.Engine, injector *wirex.Injector, opts *EngineOptions) error
RegisterTo mounts admin middlewares and /api/v1 routes onto an existing gin.Engine. Safe for embed hosts that already own the engine (e.g. tokenlive-standalone).
Types ¶
type CaptchaRedisStore ¶
type CaptchaRedisStore struct {
// contains filtered or unexported fields
}
CaptchaRedisStore implements captcha.Store interface using redis v9 client
func NewCaptchaRedisStore ¶
func NewCaptchaRedisStore(cli *redis.Client, expiration time.Duration, prefix string) *CaptchaRedisStore
NewCaptchaRedisStore creates a new CaptchaRedisStore instance
func (*CaptchaRedisStore) Get ¶
func (s *CaptchaRedisStore) Get(id string, clear bool) []byte
Get retrieves the captcha digits from redis and optionally deletes it
func (*CaptchaRedisStore) Set ¶
func (s *CaptchaRedisStore) Set(id string, digits []byte)
Set stores the captcha id and digits in redis
type EngineOptions ¶
type EngineOptions struct {
// DisableHealth skips GET /health (host may register its own).
DisableHealth bool
// DisableSwagger skips openapi/swagger routes.
DisableSwagger bool
// DisableStatic skips SPA static middleware even if Static.Dir is set.
DisableStatic bool
// DisableNoRoute skips NoMethod/NoRoute handlers (useful when sharing a host gin.Engine).
DisableNoRoute bool
}
EngineOptions controls optional HTTP surfaces when building/registering the admin engine.
type RunConfig ¶
type RunConfig struct {
WorkDir string // Working directory
Configs string // Directory or files (multiple separated by commas)
StaticDir string // Static files directory
}
RunConfig defines the config for run command.
type Runtime ¶
type Runtime struct {
Injector *wirex.Injector
CleanInjector func()
CleanLogger func()
Ctx context.Context
}
Runtime holds an initialized admin stack without listening. Used by adminapp embed facade and by Run (CLI).