From a8e947e93d2c06344a708a71e22787c20af9c2a6 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 18 Dec 2020 02:06:52 -0600 Subject: [PATCH] Add health check endpoint Fix https://github.com/matrix-org/dendrite/issues/1668 --- setup/base.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup/base.go b/setup/base.go index acbf2d35..fd4e96f0 100644 --- a/setup/base.go +++ b/setup/base.go @@ -26,6 +26,7 @@ import ( "github.com/matrix-org/dendrite/internal/caching" "github.com/matrix-org/dendrite/internal/httputil" "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/util" "github.com/prometheus/client_golang/prometheus/promhttp" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" @@ -311,6 +312,17 @@ func (b *BaseDendrite) SetupAndServeHTTP( } } + externalRouter.Handle("/health", + httputil.MakeExternalAPI("health", func(req *http.Request) util.JSONResponse { + return util.JSONResponse{ + Code: http.StatusOK, + JSON: struct { + Versions bool `json:"success"` + }{true}, + } + }), + ).Methods(http.MethodGet) + internalRouter.PathPrefix(httputil.InternalPathPrefix).Handler(b.InternalAPIMux) if b.Cfg.Global.Metrics.Enabled { internalRouter.Handle("/metrics", httputil.WrapHandlerInBasicAuth(promhttp.Handler(), b.Cfg.Global.Metrics.BasicAuth))