-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Fiber version
2.14 and above
Issue description
Session middleware is unable to lookup via given key
Code snippet
package main
import (
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/session"
)
func main() {
store := session.New(session.Config{
KeyLookup: "header:session",
})
app := fiber.New()
app.Get("/token", func(c *fiber.Ctx) error {
sess, err := store.Get(c)
if err != nil {
panic(err)
}
original := sess.Get("token")
token := c.Query("token")
if original == nil {
sess.Set("token", token)
if err := sess.Save(); err != nil {
return c.SendStatus(http.StatusInternalServerError)
}
return c.SendStatus(http.StatusAccepted) // <- however this is instead return every time
}
return c.JSON(map[string]string{"original": original.(string), "new": token}) // <- this should return if session exists
})
app.Listen(":8080")
}Reproducing
curl --request GET --header 'session: session' --url 'http://localhost:8080/token?token=next'
curl --request GET --header 'session: session' --url 'http://localhost:8080/token'Responses on 2.13
HTTP 202
Accept
HTTP 200
{
"new": "",
"original": "next"
}Responses on 2.14++
HTTP 202
Accept
HTTP 202
Accept