HTTP Routing
If API type is HTTP, this tab is visible.
Enabling Routing/Upstream Settings
The visual containing the enabling settings for routing/upstream settings is shown below:
The parameters used for enabling routing/upstream settings are shown below.
| Field | Description |
|---|---|
| If enabled, the routing/upstream settings can be made. (If enabled, the routing/upstream settings can be made.) | By enabling this setting, how traffic will be routed is managed. If closed, requests do not go to backend, if open, backend information to go to can be entered. |
| If enabled, mirroring is activated; otherwise, sample response from the specification is returned. (If enabled, mirroring is activated; otherwise, sample response from the specification is returned.) | This setting appears only if the above setting is inactive, i.e., requests are not going to any backend. With this setting, mock data can be returned or the request can be returned by copying it to the response. When enabled, the request message is copied to the response message and the response line is executed; when disabled, the result expected to return in code 200 in the definition file is returned. |
Disable Routing
If routing is disabled, requests are not forwarded to the backend. Depending on your configuration, Apinizer can return responses based on the API definition file (spec) or mirror behavior without calling the upstream service.
Routing Tab settings are shown in the following image:
Managing Backend API Addresses
When creating an API Proxy, the Backend API's access address can be obtained in different ways:
- If an API Definition File is used, at least one of the addresses in this file is selected by the user.
- If an API Proxy is created with the No-Spec API option (for example, for a Backend API developed with code-first approach), the Backend API's address is entered by the user.
- If an API Proxy is created for an API created with API Creator (DB-2-API, Mock API or Script-2-API), address is not requested, it is managed by Apinizer. The Routing Tab is closed for these types of APIs.
The address information obtained during creation can be changed later, new addresses can be defined, or existing ones can be deleted. For this, the Addresses (Addresses) section in the Routing Tab is used.
Adding New Address
A new address can be added from the window that opens when the ➕ button in the column header area at the far right of the window opened with the Configure button is clicked.
In the new address addition window:
- Backend API address is entered in the Address field or environment variable is used
- Environment Variables Selection Dialog can be opened by clicking the list icon button on the right of the Address field
- Selected environment variable is copied to clipboard and pasted into the Address field
- Conditional routing can be defined with the Condition section
Updating Address
The address can be updated in the window that opens when the Configure button in the Address (Address) column of the table showing addresses is clicked.
If this value is desired to change automatically according to the environment it is in, selection can be made from Environment Variables (Environment Variable).
When the list icon button on the right of the address input field is clicked, the Environment Variables Selection Dialog opens. Through this dialog, all environment variables (Environment Variables) defined in the project can be viewed and selected.
When the list icon button on the right of the address input field is clicked, the Environment Variables Selection Dialog opens. Through this dialog, all environment variables (Environment Variables) defined in the project can be viewed and selected.
In the Environment Variables Selection Dialog:
- All environment variables are listed (Global and Environment-Specific)
- Filtering can be done by variable name or description with the search box
- Key Name, Description, Type information is displayed for each variable
- The format of the selected variable (
${variableName}) is automatically copied to clipboard with the Copy button - The copied value can be used by pasting it into the Address field
Example Usage:
- Environment variable:
BACKEND_URL = dev-api.example.com(for Development environment) - Environment variable:
BACKEND_URL = api.example.com(for Production environment) - Value entered in Address field:
${BACKEND_URL} - At runtime in Development environment:
dev-api.example.com - At runtime in Production environment:
api.example.com
If the API Proxy's type is SOAP; the SOAP Type information added/edited in this section is reflected to the port information in the WSDL.
Conditional Routing
The Condition section in the window opened for address update or addition operations provides the ability to define conditions for messages from clients to be sent to this address. Thus, for example, requests that do not come with a special header or parameter value can be routed to only certain one or more of the defined addresses.
A practical usage scenario example could be routing requests coming with "test=true" parameter to the test server, and requests that do not contain this parameter to the production server. Another scenario could be routing requests to servers in different regions according to the IP value of the requests.
Deleting Address
The address is deleted by selecting the Remove option from the dropdown menu at the end of the row of the address to be deleted.
At least one address is required for the API Proxy to route. Therefore, after deleting the last address, the save button becomes inactive and does not allow saving.