Fiber version/commit: Latest
Issue description
Not sure if this is intentional or somewhat of a bug.
Currently, many properties of the request context are returned as strings but are unsafe to persist after the handler has returned (due to unsafe conversion here).
Expected behavior
It should be possible to safely store request properties for reuse after the handler has returned.
Steps to reproduce
See code snippet. Send a few requests in quick succession, e.g.:
for (( c=1; c<=10; c++ )); do curl "http://localhost:3000/$c"; done
The second fmt.Printf will not output the correct value.
Code snippet
package main
import (
"fmt"
"time"
"github.com/gofiber/fiber"
)
func main() {
app := fiber.New()
app.Get("/:number", func(c *fiber.Ctx) {
number := c.Params("number")
go myfunc(number)
c.Send(number)
})
app.Listen(3000)
}
func myfunc(number string) {
fmt.Printf("number is %s \n", number)
time.Sleep(1 * time.Second)
fmt.Printf("number is now %s \n", number)
}
Fiber version/commit: Latest
Issue description
Not sure if this is intentional or somewhat of a bug.
Currently, many properties of the request context are returned as strings but are unsafe to persist after the handler has returned (due to unsafe conversion here).
Expected behavior
It should be possible to safely store request properties for reuse after the handler has returned.
Steps to reproduce
See code snippet. Send a few requests in quick succession, e.g.:
The second
fmt.Printfwill not output the correct value.Code snippet