API Gateway 10.11 | Administering API Gateway | Operating API Gateway | General Administration Configuration | URL Aliases | Example: Usage Scenarios of URL Aliases
 
Example: Usage Scenarios of URL Aliases
This section explains how an API consumer can invoke an API for which a URL alias is created. This example uses the RESTCalcService API. Suppose, the RESTCalcService API is activated in API Gateway and following are the gateway endpoints for this API:
*http://test:2225/gateway/RESTCalcService/1.0
*http://test:4000/gateway/RESTCalcService/1.0
*http://test:4010/gateway/RESTCalcService/1.0
*http://test:5555/gateway/RESTCalcService/1.0
Also, the RESTCalcService consists of the postCalc resource path that adds two numbers.
If this API is published to the API consumer then the invocation endpoint for the consumer may appear as:
https://test:5555/gateway/RESTCalcService/1.0/postCalc
If you do not want to expose the API name and path information or if you want to shorten the invocation endpoint as it is complex, then you can create a custom URL alias. To create a URL alias:
1. Expand the menu options icon , in the title bar, and select Administration.
2. Select General > URL aliases.
3. Click Add URL alias and provide the following values:
Field
Value
Alias
calc
Default URL path
gateway/RESTCalcService/1.0/postCalc
4. Click Save.
Suppose, the URL alias name provided while creating a URL alias is calc. You can now expose the https://test:5555/calc invocation endpoint to the API consumer instead of https://test:5555/gateway/RESTCalcService/1.0/postCalc.
With the default URL path specified in alias configuration, the API consumer can use this URL alias for any ports of gateway endpoint shown in the API details page, for example,
*http://test:2225/calc
*http://test:4000/calc
*http://test:4010/calc
*http://test:5555/calc
Additionally, you can use port mapping, if you want to use the same alias for a different resource path. This can be done by providing a different resource path for each port, instead of the default URL path in alias configuration. To use the same alias for a different resource path:
1. Expand the menu options icon , in the title bar, and select Administration.
2. Select General > URL aliases.
3. Click Add URL alias and provide the following values:
Field
Value
Alias
calc
Port number
5555
URL path
gateway/RESTCalcService/1.0/postCalc
4. Click +Add to add port mappings to multiple destinations and provide the following values:
Field
Value
Port number
4000
URL path
gateway/RESTCalcService/1.0/deleteCalc
5. Click Save.
Note:
As the Default URL path is not provided, the incoming call for ports other than 4000 and 5555 fails. If the Default URL path is provided then the port mapping takes the first precedence. If the value of the port does not match, then the Default URL path is used.
For the alias calc, each port is mapped to a different resource, for the invocation endpoint:
*https://test03:4000/calc: RESTCalcService/1.0/deleteCalc resource is invoked.
*https://test03:4010/calc: error appears as the default URL is not provided and a path is not configured for the 4010 port.
*https://test03:5555/calc: RESTCalcService/1.0/postCalc resource is invoked.