From 31ab083f8aaa54bfb55c1e88a608d1121279fd30 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 13 May 2023 22:33:38 +0200 Subject: [PATCH] handlers: add health-check endpoints --- app/routes.go | 4 ++++ handlers/handlers.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/app/routes.go b/app/routes.go index a47aad9..3268f44 100644 --- a/app/routes.go +++ b/app/routes.go @@ -34,6 +34,10 @@ func (a *App) SetupRoutes() { // alternative: // e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", assets))) e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets))) + + e.GET("/healthz", handlers.Healthz()) + e.GET("/health", handlers.Healthz()) + e.GET("/", handlers.Index()) e.GET("/signin", handlers.Signin()) e.POST("/signin", handlers.SigninPost(a.db)) diff --git a/handlers/handlers.go b/handlers/handlers.go index 077b6f9..252228d 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -52,6 +52,12 @@ func Index() echo.HandlerFunc { } } +func Healthz() echo.HandlerFunc { + return func(c echo.Context) error { + return c.String(http.StatusOK, "{\"status\": \"OK\"}") + } +} + func addHeaders(c echo.Context) { c.Response().Writer.Header().Set("Cross-Origin-Opener-Policy", "same-origin") }