summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-12-26 06:31:52 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-12-26 06:31:52 +0530
commit9f6a96ae733a9bf57a20cb3004a8e8f6f5f63b9f (patch)
treec2d34d783cb6b86fa4dbd6a3c50e8ad9d0f37d9b
parent36cd2854d0cfbe0345623deadbfbde77c974d80c (diff)
server.go & handlers: Add health check on / endpoint to show API running status
-rw-r--r--handlers/handlers.go4
-rw-r--r--server.go1
2 files changed, 5 insertions, 0 deletions
diff --git a/handlers/handlers.go b/handlers/handlers.go
index c15da0a..b0a0c29 100644
--- a/handlers/handlers.go
+++ b/handlers/handlers.go
@@ -35,6 +35,10 @@ func init() {
}
}
+func HealthCheck(c echo.Context) error {
+ return c.JSON(http.StatusOK, map[string]string{"message": "API is running!"})
+}
+
// handleError handles errors by logging and returning a JSON response
func handleError(c echo.Context, errMsg string, status int) error {
log.Println(errMsg)
diff --git a/server.go b/server.go
index ae3d9a6..69b3a37 100644
--- a/server.go
+++ b/server.go
@@ -24,6 +24,7 @@ func main() {
}
e := echo.New()
+ e.GET("/", handlers.HealthCheck)
e.POST("/upload", handlers.AddHash)
e.POST("/verify", handlers.VerifyHash)