X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bef56b9a22efac9ce73006623080e84a0b57f243..f4707d4ab4a998a2af2a489141393fc4e793ee89:/lib/controller/handler.go diff --git a/lib/controller/handler.go b/lib/controller/handler.go index 25799aae9e..0c31815cba 100644 --- a/lib/controller/handler.go +++ b/lib/controller/handler.go @@ -68,7 +68,7 @@ func (h *Handler) setup() { }) hs := http.NotFoundHandler() hs = prepend(hs, h.proxyRailsAPI) - hs = prepend(hs, h.proxyRemoteCluster) + hs = h.setupProxyRemoteCluster(hs) mux.Handle("/", hs) h.handlerStack = mux @@ -121,11 +121,14 @@ func prepend(next http.Handler, middleware middlewareFunc) http.Handler { }) } -func (h *Handler) proxyRailsAPI(w http.ResponseWriter, req *http.Request, next http.Handler) { +// localClusterRequest sets up a request so it can be proxied to the +// local API server using proxy.Do(). Returns true if a response was +// written, false if not. +func (h *Handler) localClusterRequest(w http.ResponseWriter, req *http.Request, filter ResponseFilter) bool { urlOut, insecure, err := findRailsAPI(h.Cluster, h.NodeProfile) if err != nil { httpserver.Error(w, err.Error(), http.StatusInternalServerError) - return + return true } urlOut = &url.URL{ Scheme: urlOut.Scheme, @@ -138,7 +141,13 @@ func (h *Handler) proxyRailsAPI(w http.ResponseWriter, req *http.Request, next h if insecure { client = h.insecureClient } - h.proxy.Do(w, req, urlOut, client) + return h.proxy.Do(w, req, urlOut, client, filter) +} + +func (h *Handler) proxyRailsAPI(w http.ResponseWriter, req *http.Request, next http.Handler) { + if !h.localClusterRequest(w, req, nil) && next != nil { + next.ServeHTTP(w, req) + } } // For now, findRailsAPI always uses the rails API running on this