added config service on startup

This commit is contained in:
James Tombleson 2024-03-31 17:47:09 -07:00
parent 6af8a2a0cd
commit 0d253270b7

View File

@ -3,6 +3,7 @@ package main
import ( import (
"database/sql" "database/sql"
v1 "go-cook/api/handlers/v1" v1 "go-cook/api/handlers/v1"
"go-cook/api/services"
"log" "log"
"net/http" "net/http"
@ -21,6 +22,8 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
cfg := services.NewEnvConfig()
e := echo.New() e := echo.New()
e.Validator = &CustomValidator{ e.Validator = &CustomValidator{
validator: validator.New(), validator: validator.New(),
@ -30,7 +33,7 @@ func main() {
e.Pre(middleware.Recover()) e.Pre(middleware.Recover())
v1Group := e.Group("/api/v1") v1Group := e.Group("/api/v1")
v1Api := v1.NewHandler(db) v1Api := v1.NewHandler(db, cfg)
v1Api.Register(v1Group) v1Api.Register(v1Group)
e.Logger.Fatal(e.Start(":1323")) e.Logger.Fatal(e.Start(":1323"))