From 580dec5b89215310ce34341e11ff17fe38bdb63a Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 8 May 2022 14:57:40 -0700 Subject: more cleanup, logging and error logging everywhere things are mostly in place can work on "features" and polish --- routes/api.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'routes/api.go') diff --git a/routes/api.go b/routes/api.go index 2fb0f3f..080d88d 100644 --- a/routes/api.go +++ b/routes/api.go @@ -6,6 +6,7 @@ import ( "time" "github.com/FChannel0/FChannel-Server/config" + "github.com/FChannel0/FChannel-Server/util" "github.com/gofiber/fiber/v2" ) @@ -20,7 +21,7 @@ func Media(c *fiber.Ctx) error { func RouteImages(ctx *fiber.Ctx, media string) error { req, err := http.NewRequest("GET", config.MediaHashs[media], nil) if err != nil { - return err + return util.MakeError(err, "RouteImages") } client := http.Client{ @@ -29,18 +30,18 @@ func RouteImages(ctx *fiber.Ctx, media string) error { resp, err := client.Do(req) if err != nil { - return err + return util.MakeError(err, "RouteImages") } defer resp.Body.Close() if resp.StatusCode != 200 { fileBytes, err := ioutil.ReadFile("./static/notfound.png") if err != nil { - return err + return util.MakeError(err, "RouteImages") } _, err = ctx.Write(fileBytes) - return err + return util.MakeError(err, "RouteImages") } body, _ := ioutil.ReadAll(resp.Body) -- cgit v1.2.3