Add /chronograf/v1/ping endpoint for server status
parent
890b3829da
commit
d57ebc65ab
|
@ -55,6 +55,8 @@ func NewMux(opts MuxOpts, service Service) http.Handler {
|
|||
router.GET("/docs", Redoc("/swagger.json"))
|
||||
|
||||
/* API */
|
||||
router.GET("/chronograf/v1/ping", service.Ping)
|
||||
|
||||
// Sources
|
||||
router.GET("/chronograf/v1/sources", service.Sources)
|
||||
router.POST("/chronograf/v1/sources", service.NewSource)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package server
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Ping responds with HTTP status 204 (no content) and if auth is available
|
||||
// refreshes the token within the cookie.
|
||||
func (h *Service) Ping(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
if h.UseAuth {
|
||||
// TODO: refresh token
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPingStatus(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", "http://hoverboards.com", nil)
|
||||
w := httptest.NewRecorder()
|
||||
srv := Service{}
|
||||
srv.Ping(w, req)
|
||||
resp := w.Result()
|
||||
if resp.StatusCode != http.StatusNoContent {
|
||||
t.Errorf("TestPingStatus got status code %d want %d", resp.StatusCode, http.StatusNoContent)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPingTokenRefresh(t *testing.T) {
|
||||
|
||||
}
|
Loading…
Reference in New Issue