Special thanks to József Sallai & Ray Mayemir
go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/keyauth/v2
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/keyauth/v2"
)
func main() {
app := fiber.New()
app.Use(keyauth.New(keyauth.Config{
KeyLookup: "cookie:access_token",
ContextKey: "my_token",
}))
app.Get("/", func(c *fiber.Ctx) error {
token, _ := c.Locals("my_token").(string)
return c.SendString(token)
})
app.Listen(":3000")
}curl -v --cookie "access_token=hello_world" http://localhost:3000