+func interceptHealthReqs(mgtToken string, checkHealth func() error, next http.Handler) http.Handler {
+ mux := httprouter.New()
+ mux.Handler("GET", "/_health/ping", &health.Handler{
+ Token: mgtToken,
+ Prefix: "/_health/",
+ Routes: health.Routes{"ping": checkHealth},
+ })
+ mux.NotFound = next
+ return ifCollectionInHost(next, mux)
+}
+
+// Determine listenURL (addr:port where server should bind) and
+// internalURL (target url that client should connect to) for a
+// service.
+//
+// If the config does not specify ListenURL, we check all of the
+// configured InternalURLs. If there is exactly one that matches our
+// hostname, or exactly one that matches a local interface address,
+// then we use that as listenURL.
+//
+// Note that listenURL and internalURL may use different protocols
+// (e.g., listenURL is http, but the service sits behind a proxy, so
+// clients connect using https).
+func getListenAddr(svcs arvados.Services, prog arvados.ServiceName, log logrus.FieldLogger) (arvados.URL, arvados.URL, error) {