From c90649369427330cb6cf98823803375c7a92d634 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 8 Feb 2020 22:44:21 +0100 Subject: [PATCH] Add more logging --- handler/create.go | 6 +++++- handler/delete.go | 6 +++++- handler/read_all.go | 6 +++++- handler/read_one.go | 6 +++++- handler/update.go | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/handler/create.go b/handler/create.go index 73de234..6063f0e 100644 --- a/handler/create.go +++ b/handler/create.go @@ -62,5 +62,9 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error { return HandleHTTPError(err, ctx) } - return ctx.JSON(http.StatusCreated, currentStruct) + err = ctx.JSON(http.StatusCreated, currentStruct) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err } diff --git a/handler/delete.go b/handler/delete.go index cc71617..8be2d61 100644 --- a/handler/delete.go +++ b/handler/delete.go @@ -59,5 +59,9 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error { return HandleHTTPError(err, ctx) } - return ctx.JSON(http.StatusOK, message{"Successfully deleted."}) + err = ctx.JSON(http.StatusOK, message{"Successfully deleted."}) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err } diff --git a/handler/read_all.go b/handler/read_all.go index c7d00b0..49decba 100644 --- a/handler/read_all.go +++ b/handler/read_all.go @@ -104,5 +104,9 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error { ctx.Response().Header().Set("x-pagination-result-count", strconv.FormatInt(int64(resultCount), 10)) ctx.Response().Header().Set("Access-Control-Expose-Headers", "x-pagination-total-pages, x-pagination-result-count") - return ctx.JSON(http.StatusOK, result) + err = ctx.JSON(http.StatusOK, result) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err } diff --git a/handler/read_one.go b/handler/read_one.go index 4a59e28..578a4cb 100644 --- a/handler/read_one.go +++ b/handler/read_one.go @@ -55,5 +55,9 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error { return HandleHTTPError(err, ctx) } - return ctx.JSON(http.StatusOK, currentStruct) + err = ctx.JSON(http.StatusOK, currentStruct) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err } diff --git a/handler/update.go b/handler/update.go index 9de1160..8c5a0f5 100644 --- a/handler/update.go +++ b/handler/update.go @@ -61,5 +61,9 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error { return HandleHTTPError(err, ctx) } - return ctx.JSON(http.StatusOK, currentStruct) + err = ctx.JSON(http.StatusOK, currentStruct) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err }