Multiple basepaths

Is there a way for an apiproxy to handle multiple basepaths?

We currently have a hard-coded API prefix on all our proxies as follows:

<ProxyEndpoint name="default">
  ...
  <HTTPProxyConnection>
    <BasePath>/api/prefix/*/service</BasePath>
    <VirtualHost>secure</VirtualHost>
  </HTTPProxyConnection>
  ...
</ProxyEndpoint> 

We'd like to remove the API prefix without breaking backwards-compatibility with the clients. For example:

<ProxyEndpoint name="default">
  ...
  <HTTPProxyConnection>
    <BasePath>/api/prefix/*/service</BasePath>
    <BasePath>/service</BasePath>
    <VirtualHost>secure</VirtualHost>
  </HTTPProxyConnection>
  ...
</ProxyEndpoint> 

Once all the clients have upgraded then we can remove the old BasePath and everyone's happy. With mobile clients, this can take several months.

I want to avoid duplicating any code.

2 5 497
5 REPLIES 5

Yes proxy can handle multiple basepath.

u can create multiple ProxyEndpoint and and defined the basepath :

10974-multiplebasepath.png

How do I do that without duplicating the code in `default`, for example?

In my case, default.xml may contain dozens of Flows, RoutingRules etc

One way to do that would be to delegate to an “internal” proxy from proxy endpoints listening on each basepath.

This article explains the internal proxy concept.You could use a LocalTargetConnection between the outward-facing proxy endpoints and the private one.

Not applicable

There is an option in proxy to save as new proxy, you can just change the basepath, save as new proxy and save the proxy with extension V2.

You will have different revisions of your api proxy know. You can deploy one revision with the base path <BasePath>/api/prefix/*/service</BasePath>.

And deploy another/next revision with the another base path <BasePath>/service</BasePath>.

It is allowed and I have worked with this approach in lower environments. It was helpful to me as I was maintaining the basepath /v1 as standard code(and provided to front-end people for testing and working from their end) and the basepath /v2 as working code.

Here, you have duplicate of code though. So kindly decide for your-self.