mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
Add the server's time in UTC to the health response.
This commit is contained in:
parent
50082a61d8
commit
a8a227b97a
2 changed files with 10 additions and 6 deletions
|
|
@ -3,6 +3,7 @@ package http
|
|||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/vault"
|
||||
)
|
||||
|
|
@ -44,9 +45,10 @@ func handleSysHealthGet(core *vault.Core, w http.ResponseWriter, r *http.Request
|
|||
|
||||
// Format the body
|
||||
body := &HealthResponse{
|
||||
Initialized: init,
|
||||
Sealed: sealed,
|
||||
Standby: standby,
|
||||
Initialized: init,
|
||||
Sealed: sealed,
|
||||
Standby: standby,
|
||||
ServerTimeUTC: time.Now().UTC().Unix(),
|
||||
}
|
||||
|
||||
// Generate the response
|
||||
|
|
@ -57,7 +59,8 @@ func handleSysHealthGet(core *vault.Core, w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
|
||||
type HealthResponse struct {
|
||||
Initialized bool `json:"initialized"`
|
||||
Sealed bool `json:"sealed"`
|
||||
Standby bool `json:"standby"`
|
||||
Initialized bool `json:"initialized"`
|
||||
Sealed bool `json:"sealed"`
|
||||
Standby bool `json:"standby"`
|
||||
ServerTimeUTC int64 `json:"server_time_utc"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ func TestSysHealth_get(t *testing.T) {
|
|||
}
|
||||
testResponseStatus(t, resp, 200)
|
||||
testResponseBody(t, resp, &actual)
|
||||
expected["server_time_utc"] = actual["server_time_utc"]
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue