adminapp

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package adminapp is the public embed facade for tokenlive-admin. External hosts (tokenlive-standalone) can Init + Register onto a shared Gin engine without starting the CLI server or calling os.Exit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is an initialized admin runtime (DB, mods, optional HTTP).

func New

func New(ctx context.Context, opt Options) (*App, error)

New loads config, wire, mods Init. Does not listen and does not block.

func (*App) Handler

func (a *App) Handler() http.Handler

Handler returns an http.Handler with a dedicated Gin engine (builds once).

func (*App) LoadGatewaySnapshot

func (a *App) LoadGatewaySnapshot(ctx context.Context) (*GatewaySnapshot, error)

LoadGatewaySnapshot loads routing config, policies, and API keys from the admin DB (same data as Gateway Sync HTTP APIs, without network or sync token).

func (*App) Register

func (a *App) Register(ctx context.Context, e *gin.Engine) error

Register mounts admin API (and optional swagger/SPA) on e.

func (*App) Shutdown

func (a *App) Shutdown(ctx context.Context) error

Shutdown stops HTTP (if Start was used), releases mods, and cleans DI/logger. Does not call os.Exit.

func (*App) Start

func (a *App) Start(ctx context.Context) error

Start listens on admin HTTP addr from config (CLI-compatible path without util.Run/os.Exit). Host should still call Shutdown. For full CLI signal loop, use bootstrap.Run.

type GatewaySnapshot

type GatewaySnapshot struct {
	ConfigJSON   []byte
	PoliciesJSON []byte
	APIKeysJSON  []byte
}

GatewaySnapshot is JSON-encoded admin gateway export (same shape as /api/v1/gateway/*). Hosts unmarshal into tokenlive-gateway config types without importing admin internal packages.

type Options

type Options struct {
	WorkDir   string // default "configs"
	Configs   string // relative to WorkDir, default "dev"
	StaticDir string // SPA directory; empty skips static middleware

	// Engine, if non-nil, is used for Register (host-owned). New does not listen.
	Engine *gin.Engine

	// When Engine is set, these defaults avoid clobbering host routes.
	// DisableHealth defaults true if Engine != nil.
	// DisableNoRoute defaults true if Engine != nil.
	DisableHealth  *bool
	DisableNoRoute *bool
	DisableSwagger bool
	DisableStatic  bool

	// OnConfigChanged is invoked after admin mutations that affect gateway runtime.
	// kind: endpoints | policies | apikeys | all
	OnConfigChanged util.ConfigChangeListener
}

Options configures admin embed startup.

Jump to

Keyboard shortcuts

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