Documentation
¶
Overview ¶
Package framework provides Gombit's runtime application lifecycle and HTTP surfaces (Gin router escape hatch and Huma contract API).
Index ¶
- Constants
- func GetRequestID(c *gin.Context) string
- func GetRequestIDFromContext(ctx context.Context) string
- func GetTraceID(c *gin.Context) string
- func GetTraceIDFromContext(ctx context.Context) string
- func Run(app *App) error
- func RunContext(ctx context.Context, app *App) error
- type App
- func (a *App) API() huma.API
- func (a *App) Addr() string
- func (a *App) Cache() cache.Cache
- func (a *App) Config() config.Config
- func (a *App) DB() *gorm.DB
- func (a *App) Database() *database.DB
- func (a *App) Logger() *zap.Logger
- func (a *App) OnStart(hook Hook)
- func (a *App) OnStop(hook Hook)
- func (a *App) Redis() *redis.Client
- func (a *App) Router() *gin.Engine
- type Hook
- type Option
- func WithCache(c cache.Cache) Option
- func WithConfig(cfg config.Config) Option
- func WithDatabase(db *database.DB) Option
- func WithEmbeddedFrontend(fsys fs.FS) Option
- func WithLogger(logger *zap.Logger) Option
- func WithRedis(client *redis.Client) Option
- func WithRouter(router *gin.Engine) Option
- func WithShutdownTimeout(timeout time.Duration) Option
Constants ¶
const RequestIDHeader = "X-Request-Id"
RequestIDHeader is the HTTP header carrying a stable per-request ID.
const TraceIDHeader = "X-Trace-Id"
TraceIDHeader exposes the active trace ID for logs, diagnostics, and tests.
const TraceparentHeader = "Traceparent"
TraceparentHeader is the W3C trace context header.
Variables ¶
This section is empty.
Functions ¶
func GetRequestID ¶
GetRequestID returns the request ID stored in the Gin context.
func GetRequestIDFromContext ¶
GetRequestIDFromContext reads the request ID from a request context.
func GetTraceID ¶
GetTraceID returns the trace ID stored in the Gin context.
func GetTraceIDFromContext ¶
GetTraceIDFromContext reads the trace ID from a request context.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App owns Gombit's runtime lifecycle and HTTP router.
type Option ¶
Option configures an App.
func WithConfig ¶
WithConfig sets the app configuration. DocsEnabled is taken as given: Default() leaves /docs on even if you later set Environment to production. Use config.DefaultFor(env) or set API.DocsEnabled yourself.
func WithDatabase ¶
WithDatabase attaches an opened database handle to the app.
func WithEmbeddedFrontend ¶
WithEmbeddedFrontend stores fsys and, when it contains index.html at its root, installs a Gin NoRoute handler after framework routes so unmatched GET paths serve the SPA. Huma /api/*, /openapi.json, /docs, and the probe routes still win because they are registered before NoRoute runs.
If fsys has no index.html (the gombit new placeholder embed), NoRoute is not installed and unknown paths keep their current 404. Split deploy is the default (C5); embedding is opt-in via gombit build --embed.
func WithLogger ¶
WithLogger attaches a Zap logger to the app.
func WithShutdownTimeout ¶
WithShutdownTimeout sets the bounded shutdown timeout.