Documentation
¶
Overview ¶
Package server provides common bootstrapping for all Nivo services.
Index ¶
Constants ¶
View Source
const ( ReadTimeout = 15 * time.Second WriteTimeout = 15 * time.Second IdleTimeout = 60 * time.Second ShutdownTimeout = 30 * time.Second )
HTTP server timeouts
Variables ¶
This section is empty.
Functions ¶
func RequireEnv ¶
RequireEnv returns the environment variable value or panics if not set. Use this for required configuration like JWT_SECRET.
func Run ¶
func Run(cfg ServiceConfig)
Run bootstraps and runs the service with common initialization.
Types ¶
type BootstrapContext ¶
BootstrapContext contains initialized resources for service setup.
type ServiceConfig ¶
type ServiceConfig struct {
// Name is the service name (used for logging and identification).
Name string
// SetupHandler is called after DB connection to initialize
// repositories, services, and handlers. Returns the HTTP handler.
SetupHandler func(ctx *BootstrapContext) (http.Handler, error)
// Cleanup is called during graceful shutdown (optional).
// Use this for closing additional resources like Redis connections.
Cleanup func() error
}
ServiceConfig defines how to bootstrap and run a service.
Click to show internal directories.
Click to hide internal directories.