Example 10: Reading Request URL Path and Changing Backend Address
- For example, let's introduce the Petstore API to Apinizer when the Apinizer worker is running on http://10.10.10.1:30080/apigateway/.
- Let the relative path value of this API Proxy be "/apigateway/petstore".
- In this case the full address of this API Proxy would be as follows:
- For the request sent to the above address, the backend Routing URL should be:
- Let's add a script to this API Proxy.
- Let's access the following endpoint with a GET request:
- In this case, the request came to the endpoint: /pet/findByStatus
- The "requestUrlFromClient" variable in the script policy contains the value "/pet/findByStatus". If this Service was Soap, the value of this variable would be the name of the Soap method.
- When the "requestBackendUrlToTargetAPI" variable in the script policy is changed to the value "/xxx/yyy", the current query param is added to the request, regardless of which method the request comes from, and it will go to the following address: