Documentation
¶
Overview ¶
Package bootstrap wires a Fiber app — middleware, health, metrics, tracing, OpenAPI docs, i18n, and graceful shutdown — from a single Options struct.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
App wraps *fiber.App with graceful-shutdown cleanup hooks.
func New ¶
New builds a Fiber app wired with recover, request-id/context, request logging, optional CORS, optional rate limiting, and optional health endpoints.
func (*App) Mount ¶
Mount wires each module into the app. For every module it, in order:
- runs Migrate(ctx) if the module implements Migrator AND the app was built with Options{AutoMigrate: true}; when AutoMigrate is false the schema is expected to be managed by external migration tooling,
- calls Register to mount routes,
- collects Checks() if the module implements HealthChecker (they then appear in /readyz).
It stops and returns a wrapped error on the first failure.
type AsynqmonMount ¶
type AsynqmonMount struct {
Handler http.Handler // the UI handler, e.g. jobs.MonitoringHandler(opt, path)
Path string // mount path; defaults to "/monitoring"
Middleware []fiber.Handler // optional guards applied before the handler
}
AsynqmonMount configures mounting an external monitoring UI handler (e.g. the asynqmon dashboard) on the app. Kept generic so bootstrap need not import asynqmon.
type HealthChecker ¶
type HealthChecker interface {
Checks() []health.NamedCheck
}
HealthChecker is an optional Module capability: contribute readiness checks.
type Module ¶
type Module interface {
// Name identifies the module; it is used in error messages from Mount.
Name() string
// Register mounts the module's routes on r.
Register(r fiber.Router) error
}
Module is a self-contained feature that registers its own routes. Implement the optional Migrator and HealthChecker interfaces to opt into startup migration and readiness reporting.
type Options ¶
type Options struct {
Logger *logger.Logger
RequestTimeout time.Duration
ShutdownTimeout time.Duration
DB *bun.DB
EnableCORS bool
RateLimit int
RateLimitStorage fiber.Storage
SecurityHeaders bool
Compression bool
Idempotency bool
IdempotencyStorage fiber.Storage
AutoMigrate bool
Metrics bool
Tracing bool
Cleanup []func(context.Context) error
Asynqmon *AsynqmonMount
HealthChecks []health.NamedCheck
FiberConfig fiber.Config
// OpenAPI, if non-nil, mounts the OpenAPI document at OpenAPISpecURL and a
// Swagger UI at OpenAPIDocsURL.
OpenAPI *openapi.Spec
OpenAPISpecURL string // default "/openapi.json"
OpenAPIDocsURL string // default "/docs"
// I18n, if set, mounts the locale-detection middleware so handlers can use
// i18n.T / i18n.Locale.
I18n *i18n.Bundle
}
Options configures the bootstrapped app. All fields are optional.