From 337a941d0dab171e6fa3c973f34813a154b78dc9 Mon Sep 17 00:00:00 2001 From: Vishal Sharma Date: Thu, 17 Oct 2024 19:09:10 +0530 Subject: [PATCH] feat: onboarding API via proxy (#6058) * feat: onboarding API via proxy * chore: update profiles route * chore: update profiles url --- ee/query-service/app/api/gateway.go | 10 +++++++++- ee/query-service/integrations/gateway/proxy.go | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ee/query-service/app/api/gateway.go b/ee/query-service/app/api/gateway.go index 15d274ee23..1154911a26 100644 --- a/ee/query-service/app/api/gateway.go +++ b/ee/query-service/app/api/gateway.go @@ -9,7 +9,15 @@ import ( func (ah *APIHandler) ServeGatewayHTTP(rw http.ResponseWriter, req *http.Request) { ctx := req.Context() - if !strings.HasPrefix(req.URL.Path, gateway.RoutePrefix+gateway.AllowedPrefix) { + validPath := false + for _, allowedPrefix := range gateway.AllowedPrefix { + if strings.HasPrefix(req.URL.Path, gateway.RoutePrefix+allowedPrefix) { + validPath = true + break + } + } + + if !validPath { rw.WriteHeader(http.StatusNotFound) return } diff --git a/ee/query-service/integrations/gateway/proxy.go b/ee/query-service/integrations/gateway/proxy.go index 8b225c4459..493dd4130b 100644 --- a/ee/query-service/integrations/gateway/proxy.go +++ b/ee/query-service/integrations/gateway/proxy.go @@ -8,9 +8,9 @@ import ( "strings" ) -const ( +var ( RoutePrefix string = "/api/gateway" - AllowedPrefix string = "/v1/workspaces/me" + AllowedPrefix []string = []string{"/v1/workspaces/me", "/v2/profiles/me"} ) type proxy struct {