From 260f533b411606131a65b8ffded0581729dee1a7 Mon Sep 17 00:00:00 2001 From: Lakhan Samani Date: Sat, 5 Feb 2022 10:09:25 +0530 Subject: [PATCH] fix: resolves #115 --- server/handlers/health.go | 15 +++++++++++++++ server/routes/routes.go | 1 + 2 files changed, 16 insertions(+) create mode 100644 server/handlers/health.go diff --git a/server/handlers/health.go b/server/handlers/health.go new file mode 100644 index 0000000..2ee3142 --- /dev/null +++ b/server/handlers/health.go @@ -0,0 +1,15 @@ +package handlers + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +// HealthHandler is the handler for /health route. +// It states if server is in healthy state or not +func HealthHandler() gin.HandlerFunc { + return func(c *gin.Context) { + c.String(http.StatusOK, "OK") + } +} diff --git a/server/routes/routes.go b/server/routes/routes.go index f5b5770..d957f86 100644 --- a/server/routes/routes.go +++ b/server/routes/routes.go @@ -14,6 +14,7 @@ func InitRouter() *gin.Engine { router.Use(middlewares.CORSMiddleware()) router.GET("/", handlers.RootHandler()) + router.GET("/health", handlers.HealthHandler()) router.POST("/graphql", handlers.GraphqlHandler()) router.GET("/playground", handlers.PlaygroundHandler()) router.GET("/oauth_login/:oauth_provider", handlers.OAuthLoginHandler())