diff options
author | FChannel <> | 2022-05-08 14:57:40 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 580dec5b89215310ce34341e11ff17fe38bdb63a (patch) | |
tree | 894424df66a9d9f7e41805822f29adac8fb490fe /routes/api.go | |
parent | f7bf818d29393ceaccf4d2906557351fa6a4f49f (diff) |
more cleanup, logging and error logging everywhere
things are mostly in place can work on "features" and polish
Diffstat (limited to 'routes/api.go')
-rw-r--r-- | routes/api.go | 9 |
1 files changed, 5 insertions, 4 deletions
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) |