edit-icon download-icon

3. Configure Backend

Last Updated: Feb 22, 2018

Create an API: Define API backend server

Define API backend server defines the format of API requests received by the backend service. That is, you send an API call to the API gateway according to the configuration in the previous step. Then, the API gateway resolves your mapping rules and sends a request to the backend based on your requirements. This minimizes the cost of modifying the backend service and maximizes compatibility.

In other words, this step defines the request style when the gateway sends a request to your backend, to comply with the established backend format.

Step 1: Configure basic backend definitions, including the backend service address, backend request path, backend method, and timeout threshold.

Configure API backend service information

  1. Backend service address: Indicates http(s)://host:port of your backend service. This can also be a domain name. The backend service address https://a.b.com:8080 is used in this example.
  2. Backend request path: Indicates the path used by the gateway to access the backend. In the URL, the path follows the backend service address and comes before “?”. Here the backend request path is formatted as /region/group.
  3. Note that the frontend path is /getapilist. It does not have to be the same as the backend path. Also, parameters must be input in the backend path. This error report is explained in the next section.
  4. The backend method does not have to be the same as the frontend method, but it is recommended that they be consistent. Here, the POST method is used.

Step 2: Configure the backend service parameters, particularly the mapping parameters.

Backend parameter mapping

  1. As shown in the preceding figure, this step fetches the frontend input parameters configured in the preceding step. The two columns on the left highlighted in red must be changed. If the frontend and backend are consistent, they do not need to be changed.
  2. Note that, in the frontend, the region and group are configured in Query and Body; but in the backend, these parameters are to be received in Path. An error message is prompted for the previously configured Path. After changes are made as shown in the figure, this error should disappear.
  3. Adjust the configurations according to the actual parameter names and receiving positions used at the backend. The parts highlighted in red on the left of the figure must be modified for the backend. The settings on the right are the established frontend configurations and cannot be modified. If the frontend configuration changes, you still need to go back to the preceding step and modify these settings.

The completed configuration is shown in the following figure.

Creation complete

Ensure that Parameter Path is selected for the parameter positions in Path.

Constant parameters and system parameters are invisible to the API requester. They are added when the gateway sends a request for the backend service.

Constant parameters: For example, when the backend needs to receive a constant, but you do not want your users to see this value, you can configure a constant parameter, so that the constant can be received in Header or Query.

System parameters: For example, when you need to obtain the APP IDs customers use to call the API for log statistics, you can configure a system parameter, so that the APP IDs can be received in Header or Query. It is strongly recommended that the CaRequestId field be received at the backend. Each request has a unique ID to locate problems and create full logs. Refer to the following figure.

Constant and system parameters

Create an API: Define returned results

At present, return results are not resolved in the API gateway. Instead, the API gateway forwards them directly to the API requester.

Thank you! We've received your feedback.