Configure Request Execution Flow
- API Request Execution Flow
- Configure API Studio for movieinfo
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.
- API Studio issues an API request to the service running in the IDE.
- Egress requests from the service in the IDE are sent back to the API Studio proxy.
- 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.
- The responses come back from the upstream services (or mocks) to the API Studio proxy.
- The responses from cloud service (or mock service) are sent to the service in the IDE.
- 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.
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.
- 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.
- 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)
Change to: (for sending egress requests to the API Studio proxy)
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.
- 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
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.