Configure Request Execution Flow

Updated 2 weeks ago by Rahul Lahiri

Before using the API Studio, it is important to understand the expected flow of the request execution, and how API Studio provides observability into the request execution. Let us review the steps of how the request execution works with API Studio.

API Request Execution Flow

Each request starts with API Studio sending a request to an endpoint. The endpoint could be in your IDE or in your dev cluster. API Studio uses environment variables to send the same request to different hosts, for example to your localhost or to your dev cluster, without changing the API request in the API editor.

If the API endpoint is in your IDE, the egress requests from your service in the IDE should be routed back to the API Studio. From the API Studio, you can configure the egress requests to be served by live services in the cloud (for example, your dev cluster) or by Mesh Dynamics virtual services simply by setting the routing configuration from the UI. This allows you full observability and maximum flexibility.

  1. API Studio issues an API request to the service running in the IDE.
  2. Egress requests from the service in the IDE are sent back to the API Studio proxy.
  3. Depending on the configuration, API Studio forwards the upstream API request to an instance of the API in the cloud, or to the Mesh Dynamics mock services.
  4. The responses come back from the upstream services (or mocks) to the API Studio proxy.
  5. The responses from cloud service (or mock service) are sent to the service in the IDE.
  6. Finally, the response from the service in the IDE comes back to the API Studio.

Configure API Studio for movieinfo

Now we will configure the API Studio for the sample app. Follow the steps below to configure the request execution flow for the MovieInfo app. You will be setting up similar configurations when you use API Studio with your code.

Select MovieInfo app

When your account was created, two applications “Default” and “MovieInfo” were associated with it. For the following steps, ensure that the application selected is “MovieInfo”. You can switch applications by clicking on the app tab in the nav bar.

  • Click in the tab in the nav bar shown in the screenshot below. It will open to show the apps available, and the currently selected app.
  • Select the MovieInfo app and close the app bar by clicking on tab again.

Configure request endpoint

Configure API Studio to send requests to endpoints in your IDE or a live cluster. We will set up environment variables in the API Studio so that the request can be sent to the service running in the IDE or the service running in the Mesh Dynamics cloud by just switching the selected environment.

In your application, you would set up the environment variables to send requests to your IDE or to your dev cluster.
Endpoint in IDE

Set up the environment to send requests to the service running locally in your IDE.

  • Go to the API Editor page: To go to the API Editor, click on the top icon on the left nav bar.
  • Click on the gear icon shown in the screenshot (upper right corner) to open the Configure Environments dialog box.
  • Set up the configuration as shown in the screenshot, and save the configuration to a named profile, ‘localhost’.
    • Set Environment Name to localhost
    • Set Variable to url
    • Set Value to http://localhost:8080/MIRest
Endpoint in cloud

Set up the environment to send requests to the service running in the Mesh Dynamics cloud.

In your application, you would set up the environment variables to send requests to your dev cluster.
  • Click on the gear icon again.
  • Set up the configuration as shown in the screenshot below, and save the configuration to a named profile, ‘DevCluster’.
    • Set Environment Name to DevCluster
    • Set Variable to url
    • Set Value to https://moviebook.meshdynamics.io

Egress requests from IDE

For full observability, forward the egress requests from the IDE back to the API Studio. For the movieinfo service in your IDE (the code you downloaded), configure the egress requests from the service to go to the API Studio proxy.

Both configuration blocks are present in the conf file provided and the required block is uncommented. No changes are needed. These are provided as examples for configuration changes you will need to make to your application.
Mesh Dynamics mock services use port 9000 by default [Refer to App Settings section]. If you are using a different port in your setup (for example due to a conflict with another service already using port 9000), then you would need to change this configuration to use a different port.
  • Open the MIRest.conf file in your IDE.
  • Set the following configuration parameters to route the egress requests from the IDE to the API Studio, and save the file.
    Default configuration: (for sending egress requests to live services in dev cluster)
    PRODUCTPAGE_URI=http://productpage:9080
    BOOKDETAILS_URI=http://details:9080
    BOOKRATINGS_URI=http://ratings:9080
    BOOKREVIEWS_URI=http://reviews:9080
    RESTWRAPJDBC_URI=http://localhost:8080/restwrapjdbc/restsql

    Change to: (for sending egress requests to the API Studio proxy)
    PRODUCTPAGE_URI=http://localhost:9000
    BOOKDETAILS_URI=http://localhost:9000/details
    BOOKRATINGS_URI=http://localhost:9000/ratings
    BOOKREVIEWS_URI=http://localhost:9000/reviews
    RESTWRAPJDBC_URI=http://localhost:9000/restwrapjdbc/restsql

Egress requests forwarding

API Studio needs to forward egress requests to the mock server or to the dev cluster. Create a configuration to send the egress requests coming from the movieinfo service to the API Studio to the Mesh Dynamics virtual services, or to the live service in the cloud.

If you do not set up the egress request configuration in API Studio, then by default all egress requests are sent to the Mesh Dynamics virtual services
  • Click the gear icon next to the mock configuration selector as shown in the screenshot to open the Proxy Settings dialog box.
  • Setup the service configurations as shown in the screenshot, and save the configuration to a named profile, MD-demo. The service urls provided here are for Mesh Dynamics services in the demo cluster.
    • Service: details, Target url: https://moviebook.meshdynamics.io
    • Service: ratings, Target url: https://moviebook.meshdynamics.io
    • Service: restwrapjdbc, Target url: https://moviebook.meshdynamics.io
    • Service: reviews, Target url: https://moviebook.meshdynamics.io
When the ‘Mock’ box for a service is checked in the configuration, API Studio forwards all egress requests to the service to the Mesh Dynamics mock servers. If the boxes are not checked, then the egress requests are forwarded to the service specified by the url.

Next steps

Now you are ready to start using API Studio. Let us walk you through the steps to send your first request to the movieinfo service in your IDE to get a feel for the basic capabilities of API Studio.


How did we do?