Add a few useful middlewares

This commit is contained in:
Dan Jones 2023-03-26 17:54:02 -05:00
commit 60c930881b

View file

@ -3,6 +3,8 @@ package commands
import (
"codeberg.org/danjones000/lenore/config"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/spf13/cobra"
"log"
)
@ -15,6 +17,17 @@ func app(cmd *cobra.Command, args []string) {
app := fiber.New()
conf := config.GetConfig()
app.Use(func(c *fiber.Ctx) error {
c.Set("X-Clacks-Overhead", "GNU Terry Pratchett, Robin Williams")
c.Next()
return nil
})
app.Use(logger.New(logger.Config{
Format: "${time} | ${status} | ${latency} | ${method} | ${path} | ${body}\n",
TimeFormat: "2006-01-02T15:04:05",
}))
app.Use(cors.New(cors.Config{MaxAge: 3600}))
app.Get("/", func(c *fiber.Ctx) error {
return c.JSON(&conf)
})