Hello APISIX team,

I have 2 APIS.

   -

   API 1: platfrom1.com/getProducts
   -

   API 2: platform2.com/getProducts

Both APIs have the same path (getProducts) but return different results. I
want to expose them via APISIX. I can do this via two methods with APISIX.

*Scenario 1*

curl "http://127.0.0.1:9080/apisix/admin/routes/1"; -X PUT -d '

{

    "uri": "/getProducts",

    "host": "platform1.com",

    "service_id": "id_of_platform1.com"

}'

curl "http://127.0.0.1:9080/apisix/admin/routes/2"; -X PUT -d '

{

    "uri": "/getProducts",

    "host": "platform2.com",

    "service_id": "id_of_platform2.com"

}'


Then I can invoke the APIs in the following manner.

curl -i -X GET http://127.0.0.1:9080/get -H "Host: platform1.com"

curl -i -X GET http://127.0.0.1:9080/get -H "Host: platform2.com"

My requirement is I do not want the user to call the API via providing the
host attribute. The workaround is to rewrite the request.


*Scenario 2*

curl "http://127.0.0.1:9080/apisix/admin/routes/1"; -X PUT -d '

{

    "uri": "/getPlatform1Products",

     "plugins": {

        "proxy-rewrite": {

          "url": "getProdcuts",

        },

    },

    "service_id": "id_of_platform1.com"

}'


Instead of doing this I want to invoke the platform 1 functionalities like
this (having a prefix):


http://127.0.0.1:9080/*platform1*
/getProducts/some_additonal_path?additionalParams


Step 1: Configure route with the following configurations


curl "http://127.0.0.1:9080/apisix/admin/routes/1"; -X PUT -d '
{
    "uri": "/getProducts",
     "plugins": {
        "proxy-rewrite": {
          "remove_path": "platform1"
        }
    },
    "service_id": "200"
}


Step 2: Call the route.


When the platform1/getProducts is invoked proxy rewrite plugin intercepts
the call and removes the platform1 path and append the rest. Thus the final
path will look like this:

platform1/getProducts/some_additonal_path?additionalParams


Is this something the regex_uri parameter in proxy rewrite plugin can do,
or should I create a new attribute to do this modification?


-- 
Best Regards,
S.Nirojan

Reply via email to