From b920c542ddd1f0fb25b1ecf5eaaa8af70eeb24bd Mon Sep 17 00:00:00 2001 From: cmeng Date: Wed, 8 May 2024 14:26:36 +1200 Subject: [PATCH] fix(docker): keep /docker url prefix for DockerHandler EE-7073 (#11800) --- api/http/handler/docker/handler.go | 6 +++--- api/http/handler/handler.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/http/handler/docker/handler.go b/api/http/handler/docker/handler.go index 487611e63..290a57975 100644 --- a/api/http/handler/docker/handler.go +++ b/api/http/handler/docker/handler.go @@ -40,14 +40,14 @@ func NewHandler(bouncer security.BouncerService, authorizationService *authoriza } // endpoints - endpointRouter := h.PathPrefix("/{id}").Subrouter() + endpointRouter := h.PathPrefix("/docker/{id}").Subrouter() endpointRouter.Use(middlewares.WithEndpoint(dataStore.Endpoint(), "id")) endpointRouter.Use(dockerOnlyMiddleware) - containersHandler := containers.NewHandler("/{id}/containers", bouncer, dataStore, dockerClientFactory, containerService) + containersHandler := containers.NewHandler("/docker/{id}/containers", bouncer, dataStore, dockerClientFactory, containerService) endpointRouter.PathPrefix("/containers").Handler(containersHandler) - imagesHandler := images.NewHandler("/{id}/images", bouncer, dockerClientFactory) + imagesHandler := images.NewHandler("/docker/{id}/images", bouncer, dockerClientFactory) endpointRouter.PathPrefix("/images").Handler(imagesHandler) return h } diff --git a/api/http/handler/handler.go b/api/http/handler/handler.go index 76f0de99a..5ad0e3ebf 100644 --- a/api/http/handler/handler.go +++ b/api/http/handler/handler.go @@ -199,7 +199,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case strings.HasPrefix(r.URL.Path, "/api/kubernetes"): http.StripPrefix("/api", h.KubernetesHandler).ServeHTTP(w, r) case strings.HasPrefix(r.URL.Path, "/api/docker"): - http.StripPrefix("/api/docker", h.DockerHandler).ServeHTTP(w, r) + http.StripPrefix("/api", h.DockerHandler).ServeHTTP(w, r) // Helm subpath under kubernetes -> /api/endpoints/{id}/kubernetes/helm case strings.HasPrefix(r.URL.Path, "/api/endpoints/") && strings.Contains(r.URL.Path, "/kubernetes/helm"):