bootstrap

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

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

func ListenAndServe(ctx context.Context, handler http.Handler) (func(), error)

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).

func Run

func Run(ctx context.Context, runCfg RunConfig) error

The Run function initializes and starts a service with configuration and logging, and handles cleanup upon exit. CLI path uses util.Run which may os.Exit.

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).

func Init

func Init(ctx context.Context, runCfg RunConfig) (*Runtime, error)

Init loads config, logger, wire injector, mods Init, and prometheus. It does not start HTTP. Caller must invoke Release.

func (*Runtime) Release

func (rt *Runtime) Release(ctx context.Context)

Release stops mods and cleans injector/logger.

Jump to

Keyboard shortcuts

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