)
type handler struct {
- Config *Config
- clientPool *arvadosclient.ClientPool
- setupOnce sync.Once
- hmux *http.ServeMux
+ Config *Config
+ clientPool *arvadosclient.ClientPool
+ setupOnce sync.Once
+ healthHandler http.Handler
}
// parseCollectionIDFromDNSName returns a UUID or PDH if s begins with
keepclient.RefreshServiceDiscoveryOnSIGHUP()
- h.hmux = http.NewServeMux()
- h.hmux.Handle("/_health/", &health.Handler{
+ h.healthHandler = &health.Handler{
Token: h.Config.ManagementToken,
Prefix: "/_health/",
- })
+ }
}
func (h *handler) serveStatus(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(status)
}
-func (h *handler) healthCheck(w http.ResponseWriter, r *http.Request) {
- h.hmux.ServeHTTP(w, r)
-}
-
// ServeHTTP implements http.Handler.
func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
h.setupOnce.Do(h.setup)
}()
if strings.HasPrefix(r.URL.Path, "/_health/") && r.Method == "GET" {
- h.healthCheck(w, r)
+ h.healthHandler.ServeHTTP(w, r)
return
}
// SSL certificates. See
// http://www.w3.org/TR/cors/#user-credentials).
w.Header().Set("Access-Control-Allow-Origin", "*")
+ w.Header().Set("Access-Control-Expose-Headers", "Content-Range")
}
arv := h.clientPool.Get()