feat: onboarding API via proxy (#6058)

* feat: onboarding API via proxy

* chore: update profiles route

* chore: update profiles url
This commit is contained in:
Vishal Sharma 2024-10-17 19:09:10 +05:30 committed by GitHub
parent fc4b55cb34
commit 337a941d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -9,7 +9,15 @@ import (
func (ah *APIHandler) ServeGatewayHTTP(rw http.ResponseWriter, req *http.Request) { func (ah *APIHandler) ServeGatewayHTTP(rw http.ResponseWriter, req *http.Request) {
ctx := req.Context() 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) rw.WriteHeader(http.StatusNotFound)
return return
} }

View File

@ -8,9 +8,9 @@ import (
"strings" "strings"
) )
const ( var (
RoutePrefix string = "/api/gateway" RoutePrefix string = "/api/gateway"
AllowedPrefix string = "/v1/workspaces/me" AllowedPrefix []string = []string{"/v1/workspaces/me", "/v2/profiles/me"}
) )
type proxy struct { type proxy struct {