add validator

This commit is contained in:
kandrusyak
2023-08-02 01:51:27 +03:00
parent c55df47ada
commit 3a514800e6
6 changed files with 59 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import (
"astra-events/config"
"astra-events/handler"
"astra-events/model"
"github.com/go-playground/validator/v10"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"gorm.io/driver/postgres"
@@ -38,7 +39,9 @@ func main() {
db.AutoMigrate(&model.Event{})
var h = &handler.Handler{DB: db}
validate := validator.New()
var h = &handler.Handler{DB: db, Validator: validate}
e.POST("/", h.CreateEvent)
e.GET("/:id", h.GetEvent)