Documentation
¶
Index ¶
- type Engine
- func (e *Engine) GetRenderAuthenticator() port.RenderAuthenticator
- func (e *Engine) OnShutdown(fn func(ctx context.Context) error) *Engine
- func (e *Engine) OnStart(fn func(ctx context.Context) error) *Engine
- func (e *Engine) RegisterInjector(inj port.Injector) *Engine
- func (e *Engine) Run() error
- func (e *Engine) RunMigrations() error
- func (e *Engine) SetDesignTokens(tokens pdfrenderer.TypstDesignTokens) *Engine
- func (e *Engine) SetFrontendFS(fsys fs.FS) *Engine
- func (e *Engine) SetI18nFilePath(path string) *Engine
- func (e *Engine) SetInitFunc(fn port.InitFunc) *Engine
- func (e *Engine) SetMapper(m port.RequestMapper) *Engine
- func (e *Engine) SetRenderAuthenticator(auth port.RenderAuthenticator) *Engine
- func (e *Engine) SetWorkspaceInjectableProvider(p port.WorkspaceInjectableProvider) *Engine
- func (e *Engine) UseAPIMiddleware(mw gin.HandlerFunc) *Engine
- func (e *Engine) UseMiddleware(mw gin.HandlerFunc) *Engine
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 NewWithConfig ¶
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 ¶
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 ¶
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 ¶
RegisterInjector adds a custom injector to the engine. Multiple injectors can be registered.
func (*Engine) Run ¶
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 ¶
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 ¶
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 ¶
SetI18nFilePath sets the path to user-provided i18n translations file.
func (*Engine) SetInitFunc ¶
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.