feat: Update internal HTTP server to use Fiber v2 with new routes and middleware configuration
This commit is contained in:
9
internal/controller/index.go
Normal file
9
internal/controller/index.go
Normal 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
14
internal/http/router.go
Normal 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
20
internal/http/server.go
Normal 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")
|
||||
}
|
Reference in New Issue
Block a user