@@ -30,6 +30,8 @@ func newRestApi(ctx context.Context) http.Handler {
30
30
mux := httputils .NewMethodMux ()
31
31
32
32
mux .GET .HandleFunc ("/alerts" , func (w http.ResponseWriter , r * http.Request ) {
33
+ noCacheHeaders (w )
34
+
33
35
handleJsonOutput (w , app .State .ActiveAlerts ())
34
36
})
35
37
@@ -57,6 +59,8 @@ func newRestApi(ctx context.Context) http.Handler {
57
59
mux .GET .HandleFunc ("/alerts/acknowledge" , func (w http.ResponseWriter , r * http.Request ) {
58
60
id := r .URL .Query ().Get ("id" )
59
61
62
+ noCacheHeaders (w )
63
+
60
64
if err := alertAck (r .Context (), id ); err != nil {
61
65
http .Error (w , err .Error (), http .StatusInternalServerError )
62
66
return
@@ -66,13 +70,17 @@ func newRestApi(ctx context.Context) http.Handler {
66
70
})
67
71
68
72
mux .GET .HandleFunc ("/deadmansswitches" , func (w http.ResponseWriter , r * http.Request ) {
73
+ noCacheHeaders (w )
74
+
69
75
handleJsonOutput (w , app .State .DeadMansSwitches ())
70
76
})
71
77
72
78
// /deadmansswitch/checkin?subject=ubackup_done&ttl=24h30m
73
79
mux .GET .HandleFunc ("/deadmansswitch/checkin" , func (w http.ResponseWriter , r * http.Request ) {
74
80
// same semantic hack here as acknowledge endpoint
75
81
82
+ noCacheHeaders (w )
83
+
76
84
// handles validation
77
85
handleDeadMansSwitchCheckin (w , r , alertmanagertypes.DeadMansSwitchCheckinRequest {
78
86
Subject : r .URL .Query ().Get ("subject" ),
@@ -173,3 +181,7 @@ func runStandaloneRestApi(ctx context.Context, logger *log.Logger) error {
173
181
func ackLink (alert amstate.Alert ) string {
174
182
return os .Getenv ("API_ENDPOINT" ) + "/alerts/acknowledge?id=" + alert .Id
175
183
}
184
+
185
+ func noCacheHeaders (w http.ResponseWriter ) {
186
+ w .Header ().Set ("Cache-Control" , "no-store, must-revalidate" )
187
+ }
0 commit comments