2020-07-06 23:07:21 +00:00
|
|
|
/*
|
|
|
|
Copyright 2020 VMware, Inc.
|
|
|
|
SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type healthzResponse struct {
|
|
|
|
Status string `json:"status"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type healthzHandler struct{}
|
|
|
|
|
|
|
|
func (h healthzHandler) ServeHTTP(responseWriter http.ResponseWriter, _ *http.Request) {
|
|
|
|
response := healthzResponse{"OK"}
|
|
|
|
js, _ := json.Marshal(response)
|
2020-07-07 20:41:05 +00:00
|
|
|
responseWriter.Header().Set(headerNameContentType, jsonMimeType)
|
2020-07-06 23:07:21 +00:00
|
|
|
_, _ = responseWriter.Write(js)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newHealthzHandler() http.Handler {
|
|
|
|
return healthzHandler{}
|
|
|
|
}
|