Skip to content

Commit

Permalink
use a string template for probes response
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Oct 4, 2019
1 parent 451a973 commit 9f7a667
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
const (
ContentType = "Content-Type" // ContentType header key
ContentTypeJSON = "application/json; charset=utf-8" // ContentTypeJSON content type for json requests

jsonResp = `{"status":"%s","version":"%s","build_time":"%s"}`
)

var version = "development"
Expand All @@ -25,7 +27,8 @@ func NewLivenessHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(ContentType, ContentTypeJSON)
resp := fmt.Sprintf(
`{"status":"Kubernetes I'm ok', no need to restart me,"version":"%s","build_time":"%s"}`,
jsonResp,
"Kubernetes I'm ok', no need to restart me",
version,
buildTime)

Expand All @@ -38,7 +41,8 @@ func NewReadinessHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(ContentType, ContentTypeJSON)
resp := fmt.Sprintf(
`{"status":"Kubernetes I'm ok', you can send requests to me,"version":"%s","build_time":"%s"}`,
jsonResp,
"Kubernetes I'm ok', you can send requests to me",
version,
buildTime)

Expand Down

0 comments on commit 9f7a667

Please sign in to comment.