Add ping handler

This commit is contained in:
Darren Shepherd 2019-01-31 15:42:27 -07:00
parent 804a341a2c
commit 1826084b24

View File

@ -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)
})
}