Publishing APIs to API7 Gateway
Once the API development is completed, it needs to be published to the API7 Gateway to leverage various powerful capabilities offered by API7.
Before the API is deployed and released, thorough testing and configuration debugging should be performed to ensure the stability of the production environment.
This article demonstrates the process using a mock API created in Postman based on the Designing APIs.
Prerequisites
Configuring APIs Manually
Create Upstream
Set the Postman Mock Server as an upstream.
Refer to the documentation on Create an upstream.In 9. Fill in the form, use the following configuration:
Name: shop_server
Targets: Mock Server address
Hostname: Use the domain or IP from Node List
Port: 443
Scheme: HTTPs
Weight: 1
Create and Publish API
Take CreateProduct
as an example.
Refer to the documentation on Create API.In 10: Fill in the form, use the following configuration:
Name: shop_server_CreateProduct
Upstream: Select the shop_server
created in the previous step.
Path: /products
HTTP Method: GET
Publish: Enable
Importing APIs
You can quickly create multiple APIs by importing the OpenAPI file.
Import OpenAPI
Refer to the documentation on Importing OpenAPI.In 9: Fill in the form, use the following configuration:
Task Name: shop_server
Upload File: shop.yaml
Configure Upstream
Refer to the documentation on Configuring an Upstream and modify it with the correct target nodes.
In 8. Click the corresponding "Configure" button section, select the shop_server
upstream that was automatically generated when importing the OpenAPI.
In 9. Edit the properties of the upstream, edit the following properties:
Target: Mock Server address
Port: 443
Hostname: Use the domain or IP from Node List
Scheme: HTTPs
Weight: 1
Publish APIs
Refer to the documentation on Publishing an API to change the imported APIs to the published status.
Validate
Access the API through the API7 Gateway address:
curl '${API7_GATEWAY_ADDRESS}/products' \
-H "Host: www.test.com" \
-X POST
--data '{
"name": "iPhone 13 Pro",
"price": 999.99
}'
Get response:
{
"id": 1
}