diff --git a/commands/app.go b/commands/app.go index 5dcc552..5fddd11 100644 --- a/commands/app.go +++ b/commands/app.go @@ -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) })