From bdc4b51c0ec0b819abd314d2a7e37cdef12e5522 Mon Sep 17 00:00:00 2001 From: Alex Wellnitz Date: Fri, 12 Sep 2025 16:32:00 +0200 Subject: [PATCH] feat: add error handling in api handler --- api/cache.go | 2 ++ pkg/cache/distribution.go | 1 + pkg/cache/ping.go | 4 ++++ 3 files changed, 7 insertions(+) create mode 100644 pkg/cache/distribution.go create mode 100644 pkg/cache/ping.go diff --git a/api/cache.go b/api/cache.go index 1c36c01..10de5cd 100644 --- a/api/cache.go +++ b/api/cache.go @@ -16,6 +16,8 @@ func GetItem(cache *cache.Cache) echo.HandlerFunc { if found { resp = fmt.Sprintf("%+v", cachedObj) + } else { + return c.String(http.StatusNotFound, "Key not found") } return c.String(http.StatusOK, resp) diff --git a/pkg/cache/distribution.go b/pkg/cache/distribution.go new file mode 100644 index 0000000..08bf029 --- /dev/null +++ b/pkg/cache/distribution.go @@ -0,0 +1 @@ +package cache diff --git a/pkg/cache/ping.go b/pkg/cache/ping.go new file mode 100644 index 0000000..d69bf8a --- /dev/null +++ b/pkg/cache/ping.go @@ -0,0 +1,4 @@ +package cache + +func Initialize() { +}