Merge pull request #1532 from openziti/restore.edge.client.api.hack

Restores old /edge/client/v1 coverage of the root URL
This commit is contained in:
Andrew
2023-06-22 14:30:17 -04:00
committed by GitHub
+7
View File
@@ -150,6 +150,13 @@ func (clientApi ClientApiHandler) newHandler(ae *env.AppEnv) http.Handler {
handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set(ZitiInstanceId, ae.InstanceId)
//if not /edge prefix and not /fabric, translate to "/edge/client/v<latest>", this is a hack
//that should be removed once non-prefixed URLs are no longer used.
//This will affect older go-lang enrolled SDKs and the C-SDK.
if !strings.HasPrefix(r.URL.Path, controller.RestApiRootPath) && !strings.HasPrefix(r.URL.Path, "/fabric") && !strings.HasPrefix(r.URL.Path, "/.well-known") {
r.URL.Path = controller.ClientRestApiBaseUrlLatest + r.URL.Path
}
//translate /edge/v1 to /edge/client/v1
r.URL.Path = strings.Replace(r.URL.Path, controller.LegacyClientRestApiBaseUrlV1, controller.ClientRestApiBaseUrlLatest, 1)