forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package fiber
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
)
|
||||
|
||||
// configure initializes the HTTP server, middleware and routes.
|
||||
func (ctrl *Controller) configure() {
|
||||
ctrl.createServer()
|
||||
ctrl.initMiddlewares()
|
||||
ctrl.initRoutes()
|
||||
}
|
||||
|
||||
// createServer creates Fiber with the configured transport limits and error handler.
|
||||
func (ctrl *Controller) createServer() {
|
||||
timeout := ctrl.cfg.Timeout()
|
||||
ctrl.server = fiber.New(fiber.Config{
|
||||
AppName: "messenger-lab1",
|
||||
DisableStartupMessage: true,
|
||||
Immutable: true,
|
||||
CaseSensitive: true,
|
||||
StrictRouting: true,
|
||||
BodyLimit: ctrl.cfg.MaxBodyBytes,
|
||||
Concurrency: ctrl.cfg.MaxConnections,
|
||||
ReadTimeout: timeout,
|
||||
WriteTimeout: timeout,
|
||||
IdleTimeout: timeout,
|
||||
ErrorHandler: ctrl.handleErr,
|
||||
})
|
||||
}
|
||||
|
||||
// initMiddlewares registers request logging and panic recovery middleware.
|
||||
func (ctrl *Controller) initMiddlewares() {
|
||||
ctrl.server.Use(ctrl.request)
|
||||
ctrl.server.Use(recover.New())
|
||||
}
|
||||
Reference in New Issue
Block a user