feat: Update internal HTTP server to use Fiber v2 with new routes and middleware configuration

This commit is contained in:
2025-03-25 09:51:54 +01:00
parent d51ced2c6a
commit 272f5cabcf
6 changed files with 94 additions and 0 deletions

View File

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

14
internal/http/router.go Normal file
View File

@@ -0,0 +1,14 @@
package http
import (
"git.dev-null.rocks/alexohneander/gosearch/internal/controller"
"github.com/gofiber/fiber/v2"
)
func configureRoutes(app *fiber.App) *fiber.App {
// Index
app.Get("/", controller.Index)
app.Get("/test", controller.Index)
return app
}

20
internal/http/server.go Normal file
View File

@@ -0,0 +1,20 @@
package http
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
)
func StartService() {
app := fiber.New()
// Add Logger
app.Use(logger.New(logger.Config{
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
}))
// Configure Routes
app = configureRoutes(app)
app.Listen(":3000")
}