Added directory structure for routing

This commit is contained in:
2023-07-22 14:19:12 +02:00
parent 2fba1066f8
commit 416eb415a9
7 changed files with 69 additions and 19 deletions

View File

@ -0,0 +1,20 @@
package api
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/helmet"
v1 "{{cookiecutter.module_path}}/internal/app/api/v1"
)
func ConfigureRoutes(router *fiber.App) error {
api := router.Group("/api")
api.Use(helmet.New())
err := v1.ConfigureRoutes(api)
if err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,15 @@
package v1
import (
"github.com/gofiber/fiber/v2"
)
func ConfigureRoutes(router fiber.Router) error {
v1 := router.Group("/v1")
v1.Get("/ping", func(c *fiber.Ctx) error {
return c.SendString("pong")
})
return nil
}

View File

@ -0,0 +1,19 @@
package app
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/gofiber/fiber/v2/middleware/logger"
"{{cookiecutter.module_path}}/internal/app/api"
)
func Run() error {
app := fiber.New()
app.Use(logger.New())
app.Use(compress.New())
api.ConfigureRoutes(app)
return app.Listen(":3000")
}