madhawa-gunasekara commented on issue #10238:
URL: https://github.com/apache/apisix/issues/10238#issuecomment-1952792392

   I propose adding a base_uri field at the service level in API Gateway 
configuration. This base_uri will be an optional field. When present, it will 
be appended to the route URIs associated with that service. This approach 
eliminates the need for configuring URI rewriting for each route individually, 
thus streamlining configuration management.
   
   Please find my below example configration
   
   1.) service configuration
   
   `
   curl http://127.0.0.1:9180/apisix/admin/services/200 \
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
     "base_uri" : "/abc.app"
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:1980": 1
           }
       }
   }
   `
   
   2.) route configuration
   
   `
   curl http://127.0.0.1:9180/apisix/admin/routes/100 \
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "methods": ["GET"],
       "uri": "/customer",
       "service_id": "200"
   }'
   `
   
   `
   curl http://127.0.0.1:9180/apisix/admin/routes/101 \
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "methods": ["GET"],
       "uri": "/product",
       "service_id": "200"
   }'
   `
   
   final endpoint calls
   for route 1 : `http://127.0.0.1:1980/abc.app/customer`
   for route 2 : `http://127.0.0.1:1980/abc.app/product`
   
   This setup ensures that the base_uri configured at the service level is 
automatically appended to the URIs of all routes associated with that service, 
simplifying configuration and management tasks.
   
   By adopting this approach, you can effectively utilize the base_uri field to 
construct the final URIs for your routes without the need for repetitive URI 
rewriting configurations.
   
   I can check to implement this as feature, what do you think? 
   I think this will be a good additional feature for the services


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to