dashboard

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package dashboard serves the admin SPA and its backing JSON API.

@title llm-router API @version 0.4 @description OpenAI-compatible plus Anthropic-compatible LLM routing gateway. @description Public AI surface (/v1, BearerAuth or x-api-key alias): @description chat/completions, completions, embeddings, images/generations, @description images/edits, images/variations, audio/speech, @description audio/transcriptions (multipart or JSON input_audio), @description audio/translations, moderations, videos submit/poll/content, @description messages, messages/count_tokens, messages/batches, complete, @description models list/retrieve (TokenRules-filtered; Anthropic shape @description when anthropic-version is present), responses (+cancel, @description input_items, compact, input_tokens), conversations (+items), @description assistants, threads (+messages, runs, cancel, @description submit_tool_outputs). Derivative-client aliases (Mistral @description random_seed/output_dimension, Ollama options/format, @description OpenRouter reasoning envelope) translate at the edge; no @description separate paths. Deprecated upstream flags are ignored: prior @description generation endpoints stay first-class, never deprecated:true. @description Dashboard surface (/api/llm-router, SessionAuth) is unchanged.

@securityDefinitions.apikey BearerAuth @in header @name Authorization @description Router token as "Bearer llmr_*".

@securityDefinitions.apikey SessionAuth @in cookie @name llmr_session @description Dashboard login session cookie.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EffectiveBootstrapped added in v0.1.2

func EffectiveBootstrapped(bootstrapped, unrestricted bool) bool

EffectiveBootstrapped is the bootstrap state the SPA acts on: the real database state, or true on the admin listener where no account exists. Single source of truth for the middleware and the status endpoint so the gate and the reported state can never diverge.

func IsAPIPath added in v0.4.0

func IsAPIPath(path string) bool

IsAPIPath reports whether path targets a JSON API subtree (/api or /v1, bare or nested). API paths never redirect and never serve SPA HTML. The shared mux routes them before the SPA fallback; the fallback rechecks here as a second boundary.

func WriteUnknownEndpoint added in v0.4.0

func WriteUnknownEndpoint(w http.ResponseWriter, _ *http.Request)

WriteUnknownEndpoint answers JSON 404 for unknown API paths, never dashboard HTML. Single definition shared by the SPA fallback and the admin listener catch-all.

Types

type Handler

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

Handler serves the admin dashboard.

func New

func New(parameters Params) (*Handler, error)

New constructs a dashboard Handler.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts every dashboard route: JSON API plus SPA.

func (*Handler) RegisterAPI added in v0.4.0

func (h *Handler) RegisterAPI(mux *http.ServeMux)

RegisterAPI mounts the JSON API routes (/api...). No SPA fallback: the admin listener serves API only and adds its own JSON catch-all.

func (*Handler) RegisterSPA added in v0.4.0

func (h *Handler) RegisterSPA(mux *http.ServeMux)

RegisterSPA mounts asset files plus the SPA fallback.

func (*Handler) SetDevRedirect

func (h *Handler) SetDevRedirect(origin string)

SetDevRedirect configures the handler to 302-redirect any browser navigation that would otherwise fall through to the embedded SPA (i.e. everything not matched by a more specific route in Register) to origin instead, preserving path and query.

This exists because `make start` never runs a real `vite build` — the embedded build/web directory is just a placeholder stub so the //go:embed directive has something to embed. Without this, hitting the backend port directly in dev (or any /login, /bootstrap navigation not proxied to the dev server) serves that meaningless placeholder instead of the actual UI, which is only running on PORT in dev. Production builds never call this, so it has no effect there.

type Params added in v0.1.2

type Params struct {
	AdminSvc     *admin.GormService
	ProviderSvc  *provider.GormService
	CredSvc      *credential.GormService
	TokenSvc     *token.GormService
	ModelInfoSvc *modelinfo.GormService
	MetricsSvc   *metrics.Service
	VirtualSvc   *virtual.GormService
	RouterSvc    *router.Service
	ConfigSvc    *configsvc.Service
	LuaSvc       *luaplugin.Service
	RepoSvc      *pluginrepo.Service
	ProxySvc     *proxypool.Service
	MaintSvc     *maintenance.GormService
	EventsSvc    *events.Service
	Logger       *slog.Logger
	// RequestShutdown signals graceful shutdown when the admin shutdown
	// endpoint fires. Required: construction fails when it is missing so
	// integrator miswiring surfaces at startup, never as a silent no-op.
	RequestShutdown func()
	// SQLiteDatabase is the SQLite handle pair backing the GORM services.
	// Required: construction fails when it is missing so integrator
	// miswiring surfaces at startup, never as a nil dereference later.
	SQLiteDatabase *db.Database
}

Params carries every dependency of the dashboard Handler in one value, so adding a service touches one struct instead of every call site.

Jump to

Keyboard shortcuts

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