Service name and API path

Updated 3 months ago by Rahul Lahiri

In the Mesh Dynamics framework, every API request must have a service name and an API path. When the requests are sent to a service, either in an IDE or in dev cluster, we derive a service and path name from the request URL. When creating mocks in the API editor, you must provide a service name and path for every API mock that you create. We recommend that whenever possible, use service names that will be meaningful to the consumers of the API mocks.

There are slight differences in how Mesh Dynamics treats the service name and API paths depending on whether the request and response are captured from a live service (either in your IDE or in a dev cluster) or a manually created mock. The differences, and how to migrate the mock requests between the formats, are explained below.

API request format for IDE

Let’s use the following example request:

http://localhost:8080/MIRest/minfo/listmovies

Service name

localhost:8080

This part of the request url specifies the localhost port the request should be sent to. This is treated as the service name by Mesh Dynamics, and becomes the service name for the mock.

API path

/MIRest/minfo/listmovies

The rest of the request url path becomes the API path for the mock.

Request format for dev cluster

Let’s use the following example request:

https://moviebook.meshdynamics.io/minfo/listmovies

Service name

moviebook.meshdynamics.io

This part of the URL is treated as the service name by Mesh Dynamics, and becomes the service name for the mock.

API path

/minfo/listmovies

The rest of the request url path becomes the API path for the mock.

Manually creating API requests

When you are manually creating the mocks in API Studio, you need to specify the service name and the API separately. For example:

Service name

movieinfo

You should use a service name that would be meaningful in your application context.

API path

/minfo/listmovies

The API path should be the same path that you would when the service goes live in a dev cluster or in your IDE.

When sending the API request to the mock servers, Mesh Dynamics concatenates the service name and the API path to form the request path:

Request Path

/movieinfo/minfo/listmovies

However, this does not specify where to send the request. Mesh Dynamics gets the host information (both domain and port) from the Target domain settings under App settings in API Studio. If you are using the Mesh Dynamics hosted solution, the mock server address is:

Target domain

https://app.meshdynamics.io

Proxy port

9000

If you are using an instance that is hosted in your VPC, the target domain and proxy port settings would be different. The settings information would be available from your systems administrator.

When the request is issued to the Mesh Dynamics mock server using the above settings, the final assembled URL will be:

https://app.meshdynamics.io:9000/movieinfo/minfo/listmovies

Example

The screenshot below shows the service name and API path setup for the example request above.

  • The service name is entered in the section for service trace (Service by Trace Order)
  • The API path in entered in the section for the request

We will go over the process in more detail in the section on creating mocks from the API Studio.


How did we do?