bootstrap

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is the main entry point for pdf-forge. Create with New(), register extensions, then call Run().

func New

func New() *Engine

New creates a new Engine with default configuration.

func NewWithConfig

func NewWithConfig(configPath string) *Engine

NewWithConfig creates a new Engine that loads config from the given file path.

func (*Engine) GetRenderAuthenticator

func (e *Engine) GetRenderAuthenticator() port.RenderAuthenticator

GetRenderAuthenticator returns the registered render authenticator, or nil if not set.

func (*Engine) OnShutdown

func (e *Engine) OnShutdown(fn func(ctx context.Context) error) *Engine

OnShutdown registers a hook that runs AFTER HTTP server stops, BEFORE exit. Hooks run synchronously in REVERSE registration order (LIFO). Use to gracefully stop background processes started in OnStart.

func (*Engine) OnStart

func (e *Engine) OnStart(fn func(ctx context.Context) error) *Engine

OnStart registers a hook that runs AFTER config/preflight, BEFORE HTTP server starts. Hooks run synchronously in registration order. For background processes (schedulers, workers), spawn a goroutine inside the hook.

func (*Engine) RegisterInjector

func (e *Engine) RegisterInjector(inj port.Injector) *Engine

RegisterInjector adds a custom injector to the engine. Multiple injectors can be registered.

func (*Engine) Run

func (e *Engine) Run() error

Run starts the engine: loads config, runs preflight checks, initializes all components, and starts the HTTP server. Blocks until shutdown signal (SIGINT/SIGTERM).

func (*Engine) RunMigrations

func (e *Engine) RunMigrations() error

RunMigrations loads config and applies all pending database migrations.

func (*Engine) SetDesignTokens

func (e *Engine) SetDesignTokens(tokens pdfrenderer.TypstDesignTokens) *Engine

SetDesignTokens sets custom design tokens for PDF rendering. Controls fonts, colors, spacing, and heading styles in Typst output. If not set, DefaultDesignTokens() is used.

func (*Engine) SetFrontendFS

func (e *Engine) SetFrontendFS(fsys fs.FS) *Engine

SetFrontendFS overrides the embedded frontend filesystem. By default, the engine loads the embedded SPA from internal/frontend/dist. Pass a custom fs.FS to serve a different frontend, or nil to disable frontend serving.

func (*Engine) SetI18nFilePath

func (e *Engine) SetI18nFilePath(path string) *Engine

SetI18nFilePath sets the path to user-provided i18n translations file.

func (*Engine) SetInitFunc

func (e *Engine) SetInitFunc(fn port.InitFunc) *Engine

SetInitFunc sets the global initialization function. Runs once before all injectors on each render request.

func (*Engine) SetMapper

func (e *Engine) SetMapper(m port.RequestMapper) *Engine

SetMapper sets the request mapper for render requests. Only ONE mapper is supported.

func (*Engine) SetRenderAuthenticator

func (e *Engine) SetRenderAuthenticator(auth port.RenderAuthenticator) *Engine

SetRenderAuthenticator sets custom authentication for render endpoints. When set, it replaces OIDC auth for render while panel OIDC continues working.

func (*Engine) SetWorkspaceInjectableProvider

func (e *Engine) SetWorkspaceInjectableProvider(p port.WorkspaceInjectableProvider) *Engine

SetWorkspaceInjectableProvider sets the provider for workspace-specific injectables. If set, the provider's GetInjectables is called when listing injectables, and ResolveInjectables is called during render for provider-owned codes.

func (*Engine) UseAPIMiddleware

func (e *Engine) UseAPIMiddleware(mw gin.HandlerFunc) *Engine

UseAPIMiddleware adds middleware to /api/v1/* routes only. Execution order: Operation -> Auth -> Identity -> Roles -> [User API Middleware] -> Controller Use for rate limiting, tenant validation, custom authorization, etc.

func (*Engine) UseMiddleware

func (e *Engine) UseMiddleware(mw gin.HandlerFunc) *Engine

UseMiddleware adds middleware to be applied globally to all routes. Execution order: Recovery -> Logger -> CORS -> [User Global Middleware] -> Routes Use for logging, tracing, custom headers, etc.

Jump to

Keyboard shortcuts

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