feat: update fiber version from 2 to 3 and add health checks

This commit is contained in:
2025-03-25 11:47:47 +01:00
parent d7a6391a08
commit a2b1abf52c
6 changed files with 65 additions and 18 deletions

View File

@@ -1,9 +1,9 @@
package controller
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v3"
)
func Index(c *fiber.Ctx) error {
func Index(c fiber.Ctx) error {
return c.SendString("Hello, World!")
}

View File

@@ -1,9 +1,9 @@
package controller
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v3"
)
func SearchQuery(c *fiber.Ctx) error {
func SearchQuery(c fiber.Ctx) error {
return c.SendString("Hello, World!")
}

View File

@@ -2,8 +2,8 @@ package http
import (
"git.dev-null.rocks/alexohneander/gosearch/internal/controller"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/monitor"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/healthcheck"
)
func configureRoutes(app *fiber.App) *fiber.App {
@@ -15,7 +15,11 @@ func configureRoutes(app *fiber.App) *fiber.App {
app.Get("/api/search/:index/:query", controller.SearchQuery)
// Monitor
app.Get("/metrics", monitor.New(monitor.Config{Title: "gosearch Metrics"}))
// app.Get("/metrics", monitor.New(monitor.Config{Title: "MyService Metrics Page"}))
// Health Checks
app.Get(healthcheck.DefaultLivenessEndpoint, healthcheck.NewHealthChecker())
app.Get(healthcheck.DefaultReadinessEndpoint, healthcheck.NewHealthChecker())
app.Get(healthcheck.DefaultStartupEndpoint, healthcheck.NewHealthChecker())
return app
}

View File

@@ -1,8 +1,8 @@
package http
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/logger"
)
func StartService() {