/
status.go
63 lines (55 loc) · 1.68 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"encoding/json"
"log"
"net/http"
)
func Status() http.HandlerFunc {
type Status struct {
Type string `json:"type"`
Initialized bool `json:"initialized"`
Sealed bool `json:"sealed"`
T int `json:"t"`
N int `json:"n"`
Progress int `json:"progress"`
Nonce string `json:"nonce"`
Version string `json:"version"`
Migration bool `json:"migration"`
ClusterName string `json:"cluster_name"`
ClusterId string `json:"cluster_id"`
RecoverySeal bool `json:"recovery_seal"`
BuildDate string `json:"build_date"`
StorageType string `json:"storage_type"`
HaEnabled bool `json:"ha_enabled"`
}
return func(w http.ResponseWriter, r *http.Request) {
var StatusResponse Status
StatusResponse.Type = "shamir"
StatusResponse.Initialized = true
StatusResponse.Sealed = false
StatusResponse.T = 1
StatusResponse.N = 1
StatusResponse.Progress = 0
StatusResponse.Nonce = ""
StatusResponse.Version = "1.11.0"
StatusResponse.Migration = false
StatusResponse.ClusterName = "vault-cluster-30a35421"
StatusResponse.ClusterId = "62b51e90-effc-19b8-b53b-027c98b2848b"
StatusResponse.RecoverySeal = false
StatusResponse.StorageType = "inmem"
StatusResponse.HaEnabled = false
StatusResponse.BuildDate = "2022-05-03T08:34:11Z"
if r.Method != "GET" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
respBody, err := json.Marshal(StatusResponse)
if err != nil {
log.Println("error encoding message JSON:", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(respBody)
}
}