From d35b955815fe9821cf9f81cbbd352237bd258d66 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 26 Apr 2024 16:04:10 -0700 Subject: [PATCH] The handler class will now store the sql connection for now --- internal/handler/v1/handler.go | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/internal/handler/v1/handler.go b/internal/handler/v1/handler.go index c1c3e93..26947c2 100644 --- a/internal/handler/v1/handler.go +++ b/internal/handler/v1/handler.go @@ -15,10 +15,11 @@ import ( ) type Handler struct { - Router *echo.Echo - Db *database.Queries - dto *dto.DtoClient - //ctx *context.Context + Router *echo.Echo + Db *database.Queries + dto *dto.DtoClient + config services.Configs + sqlConnection *sql.DB } const ( @@ -39,11 +40,12 @@ var ( ErrUnableToConvertToJson string = "Unable to convert to json" ) -func NewServer(ctx context.Context, db *database.Queries) *Handler { +func NewServer(ctx context.Context, db *database.Queries, configs services.Configs, conn *sql.DB) *Handler { s := &Handler{ - //ctx: &ctx, - Db: db, - dto: dto.NewDtoClient(db), + Db: db, + dto: dto.NewDtoClient(db), + config: configs, + sqlConnection: conn, } db, err := openDatabase(ctx) @@ -137,15 +139,3 @@ func (s *Handler) WriteError(c echo.Context, errMessage string, HttpStatusCode i Message: errMessage, }) } - -//func (s *Handler) WriteJson(w http.ResponseWriter, model interface{}) { -// w.Header().Set(HeaderContentType, ApplicationJson) -// -// bres, err := json.Marshal(model) -// if err != nil { -// s.WriteError(w, err.Error(), http.StatusInternalServerError) -// return -// } -// -// w.Write(bres) -//}