Continue migration to echo

This commit is contained in:
2022-08-20 22:23:42 +00:00
parent b573553424
commit 1a11555075
10 changed files with 168 additions and 199 deletions

View File

@@ -3,17 +3,17 @@ package server
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/labstack/echo/v4"
)
type newBudgetInformation struct {
Name string `json:"name"`
}
func (h *Handler) newBudget(c *gin.Context) {
func (h *Handler) newBudget(c echo.Context) error {
var newBudget newBudgetInformation
if err := c.BindJSON(&newBudget); err != nil {
c.AbortWithError(http.StatusNotAcceptable, err)
return echo.NewHTTPError(http.StatusNotAcceptable, err)
return
}
@@ -23,9 +23,9 @@ func (h *Handler) newBudget(c *gin.Context) {
}
userID := MustGetToken(c).GetID()
budget, err := h.Service.NewBudget(c.Request.Context(), newBudget.Name, userID)
budget, err := h.Service.NewBudget(c.Request().Context(), newBudget.Name, userID)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return echo.NewHTTPError(http.StatusInternalServerError, err)
return
}