forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathready.go
More file actions
24 lines (21 loc) · 760 Bytes
/
ready.go
File metadata and controls
24 lines (21 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package debugserver
import "net/http"
// healthzHandler is the http.HandlerFunc that responds to /healthz
// requests on the debugserver port. This always returns a 200 OK
// while the binary can be reached.
func healthzHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
// readyHandler returns an http.HandlerFunc that responds to the /ready
// requests on the debugserver port. This will return a 200 OK once the
// given channel is closed, and a 503 Service Unavailable otherwise.
func readyHandler(ready <-chan struct{}) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
select {
case <-ready:
w.WriteHeader(http.StatusOK)
default:
w.WriteHeader(http.StatusServiceUnavailable)
}
}
}