-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤗 [Question]: Lost MAP data #3195
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@RhaPT First you never call Here: func setXpto(c *fiber.Ctx) error {
xID := c.Get("X-Id", "")
Xpto[xID] = xID
log.Println(Xpto)
c.Status(fiber.StatusOK)
return c.JSON(Xpto)
} You have to copy the value form the context like this: xID := utils.CopyString(c.Get("X-Id", "")) Documentation is here: https://docs.gofiber.io/#zero-allocation |
@RhaPT Did that fix your issue? |
Thanks for your help |
Awesome 💪 |
Question Description
Sorry about my English.
I created a page with javascript where it creates a websocket and receives a unique id ("Sec-Websocket-Key") for that instance, then it uses this id whenever it makes a request to the api (sends in the header an X-Id with this value), the api stores data within a map indexed by X-Id
If you open another window in the same browser (if use other browser no problem) and call the same page, it will create a new instance for in websocket and at that time it automatically changes the MAP.
Example the first time you open the page: map[]
after adding a value : map[GlYkSNQ6GQMFtdkHGqlxZw==:GlYkSNQ6GQMFtdkHGqlxZw==]
after open new window in same browser: map[keep-aliveMFtdkHGqlxZw==:keep-aliveMFtdkHGqlxZw==]
Does anyone know why the Map changes?
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: