Continue migration to echo

This commit is contained in:
2022-08-20 22:44:59 +00:00
parent 1a11555075
commit 9da4a6f03e
10 changed files with 76 additions and 99 deletions

View File

@ -31,28 +31,25 @@ func (h *Handler) budgetingForMonth(c echo.Context) error {
budgetID := c.Param("budgetid")
budgetUUID, err := uuid.Parse(budgetID)
if err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
return
return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
}
budget, err := h.Service.GetBudget(c.Request().Context(), budgetUUID)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err)
return
}
month, err := getDate(c)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budget.ID.String())
return
}
data, err := h.getBudgetingViewForMonth(c.Request().Context(), budget, month)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err)
return
return err
}
c.JSON(http.StatusOK, data)
return c.JSON(http.StatusOK, data)
}
func (h *Handler) getBudgetingViewForMonth(ctx context.Context, budget postgres.Budget, month Month) (BudgetingForMonthResponse, error) {