Apache APISIX - Routing to different route based on param in URL

966 Views Asked by At

I am new to APISIX. Want to understand, is it feasible that I can create an API definition in APISIX, in which based on some param or different URL path, same API can route to different backend services?

I am currently using APIGEE, where I keep backend information in KVMs post extracting the mapping from our home grown service.

For instance, myapi.company.com/v1/people?tenantId=abc will redirect to backend serving abc tenantId whereas myapi.company.com/v1/people?tenantId=xyz will redirect to another backend serving xyz tenantId.

Does APISIX provide such mechanism where I can call another service to find this mapping at runtime (and cache it for consequent calls for same tenantId). And use this information to route the request to appropriate backend.

Thanks & Regards Amit

1

There are 1 best solutions below

0
Tsal Troser On

Seems possible using an advance Router config.

In Route API uri parameter it says that:

Matches the uri. For more advanced matching see Router.

In the Router page, it says you can use radixtree_uri_with_parameter for URL with parameters.

radixtree_uri_with_parameter: Like radixtree_uri but also supports parameter match.

Here's how you can configure an advance Router. https://apisix.apache.org/docs/apisix/router-radixtree/#how-to-use-libradixtree-in-apisix#5-parameter-match