From 1826084b24c18f0b3196a882f3b6388a2c21a9ef Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 31 Jan 2019 15:42:27 -0700 Subject: [PATCH] Add ping handler --- pkg/server/router.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/server/router.go b/pkg/server/router.go index 56ea168a79..83e54d654d 100644 --- a/pkg/server/router.go +++ b/pkg/server/router.go @@ -32,6 +32,7 @@ func router(serverConfig *config.Control, tunnel http.Handler, cacertsGetter CAC router.NotFoundHandler = authed router.Path("/cacerts").Handler(cacerts(cacertsGetter)) router.Path("/openapi/v2").Handler(serveOpenapi()) + router.Path("/ping").Handler(ping()) return router } @@ -100,3 +101,12 @@ func serveOpenapi() http.Handler { resp.Write(data) }) } + +func ping() http.Handler { + return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { + data := []byte("pong") + resp.Header().Set("Content-Type", "text/plain") + resp.Header().Set("Content-Length", strconv.Itoa(len(data))) + resp.Write(data) + }) +}