Improve handling of context

This commit is contained in:
2021-12-07 19:08:53 +00:00
parent fbd283cd1c
commit 1d4bc158a8
8 changed files with 21 additions and 40 deletions

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"net/http"
"git.javil.eu/jacob1123/budgeteer"
@ -23,7 +22,7 @@ func (h *Handler) budget(c *gin.Context) {
return
}
transactions, err := h.Service.DB.GetTransactionsForBudget(context.Background(), budgetUUID)
transactions, err := h.Service.DB.GetTransactionsForBudget(c.Request.Context(), budgetUUID)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
@ -45,7 +44,7 @@ func (h *Handler) newBudget(c *gin.Context) {
}
userID := c.MustGet("token").(budgeteer.Token).GetID()
_, err := h.Service.NewBudget(budgetName, userID)
_, err := h.Service.NewBudget(c.Request.Context(), budgetName, userID)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return