Split routes into own files

This commit is contained in:
2021-12-07 15:42:20 +00:00
parent 6bcf94661e
commit 0ee3f269b5
9 changed files with 497 additions and 472 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"net/http"
"git.javil.eu/jacob1123/budgeteer"
"git.javil.eu/jacob1123/budgeteer/postgres"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
@ -35,3 +36,18 @@ func (h *Handler) budget(c *gin.Context) {
c.HTML(http.StatusOK, "budget.html", d)
}
func (h *Handler) newBudget(c *gin.Context) {
budgetName, succ := c.GetPostForm("name")
if !succ {
c.AbortWithStatus(http.StatusNotAcceptable)
return
}
userID := c.MustGet("token").(budgeteer.Token).GetID()
_, err := h.Service.NewBudget(budgetName, userID)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
}