Access MSE Nacos services via HTTP API

更新时间:
复制 MD 格式

Create an HTTP API in Cloud-native API Gateway to route external requests to microservices registered in MSE Nacos. This topic covers API creation, route configuration, and debugging.

Prerequisites

  1. An MSE Nacos instance is created. Create a Nacos engine.

  2. A microservice demo is registered with MSE Nacos. Register Spring Cloud applications with an MSE Nacos registry.

    Important

    Cloud-native API Gateway does not support on-premises services registered with MSE Nacos or ZooKeeper.

  3. A Cloud-native API Gateway instance is created. Create a gateway instance.

Overview

  1. Create an HTTP API: Configure basic API information.

  2. Create a route:

    1. Configure routing rules: Map API requests to the target MSE Nacos service.

    2. Instance: Select the gateway instance for deployment.

    3. Associate a service: Link service instances to the route for dynamic discovery.

  1. Debug the route: Simulate requests to verify the gateway-to-Nacos integration.

Step 1: Create an HTTP API

  1. Log on to the API Gateway console.

  2. In the left-side navigation pane, click Cloud-native API Gateway > API. In the top navigation bar, select a region.

  3. On the API page, click Create API.

  4. In the Create API dialog box, select HTTP API and click Create. On the next page, enter an API Name and a Description.

Step 2: Create a route

Click the API name to open the details page. Click Create Route. In the Create Route panel, configure the following parameters.

Configure basic route information

image

  • Domain Name: Click Add Domain Name to create a new domain name.

  • Path: Matches requests starting with the specified path, such as /.

Instance and backend service

  1. For Instance, select your Cloud-native API Gateway instance.

    image

  2. Use case: Select Single Service.

Associate a service

  1. In the Backend Services section, click Create Service from the Service Name drop-down list.

    image

  2. Create a service source.

    1. Set Source Type to MSE Nacos.

    2. Click Add Source, select the Nacos cluster where the service is deployed, and then click OK.

    image

  3. Create a service:

    1. Namespace: Select the namespace of your demo project.

    2. Services: Select the service consumer from your microservices project.

    image

Save and publish

Step 3: Debug the route

  1. After the route is published, click Debug in the Actions column of the target route.

  2. In the debugging panel, enter the API parameters and click Send. The response appears on the right.

    image

Related documentation