Open
Description
Question Description
Problem:
When a user cancels the request (e.g., closes browser tab), processing continues. I need it to stop immediately.
What I tried:
c.Context()
β Not workingc.UserContext()
β Not working
Question:
Which context should I use to properly cancel downstream processing (service β repo β DB) when the request is cancelled?
func (h *MovieHandler) getMovies(c *fiber.Ctx) error {
// Which context to use here? π€
ctx := c.Context() // This doesn't seem to work
filter := parseFilter(c)
movies, err := h.moviesService.GetMovies(ctx, filter)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(err)
}
return c.JSON(movies)
}
Expected Behavior:
When user cancels request β all processing stops immediately β‘
Thanks for your help! π
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my questions prior to opening this one.
- I understand that improperly formatted questions may be closed without explanation.