✨ Add a few useful middlewares
This commit is contained in:
parent
12fd475ee3
commit
60c930881b
1 changed files with 13 additions and 0 deletions
|
|
@ -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)
|
||||
})
|
||||
|
|
|
|||
Reference in a new issue