Tutorial
Tutorial
TODO - Make a video demonstrating this
Introduction
This tutorial will demonstrate some of Interceptor's functionality. After following this tutorial, you should have a basic understanding of how the system works.
Prerequisites
Before starting, make sure you have a local instance of Interceptor running. You can follow the Quickstart located on the Docs Homepage.
Tutorial
Verify Interceptor is running. Visit the UI at
http://localhost:8080/ui
. You will be presented with a list of users and an option to create a new one. As this is your first time running, there will be no users.
If that address cannot be reached, you may want to revisit the quickstart to make sure everything is started locally correctly.
Create a new user 1. Click on
new
2. Enter the userfoo
into the prompt 3. Click submitClick on that user. You have now selected your user, which will allow it to keep track of your choices. You will now be presented with a list of all domains, and the option to create a new one. As this is your first time running, there will be no domains.
Create a new domain 1. Click on
new
2. Enter the nameJSON Placeholder
3. Enter the keyjsp
4. Enter the URLhttps://jsonplaceholder.typicode.com
5. Click submitJSON Placeholder is a service that just returns static mock data. We will use it to simulate an actual endpoint. If you make a GET request to https://jsonplaceholder.typicode.com/posts, you will see that it returns a static set of posts.
The proxy for this domain is also now setup. If you make a GET request to
http://localhost:8080/call/foo/jsp/posts
, Interceptor will proxy it tohttps://jsonplaceholder.typicode.com/posts
.Note that when calling through the proxy, two additional headers are set -
X-Interceptor-Domain
andX-Interceptor-User
. These identify the domain and user id.You should now be presented with a list of Intercepts for this Domain. As expected, as there are none created yet, the list is empty.
Create a new intercept 1. Click on
new
2. Enter the nameposts
3. Click createYou will now be presented with a single intercept in the intercept table. It has no conditions or responses and needs to be setup.
Click
Show Details
on the new intercept.Add a condition to the intercept to tell Interceptor when this intercept should be triggered 1. Click
new
in the Conditions section 2. Click URL pattern 3. Enterposts
4. Clicksubmit
Lock the intercept by pressing
Lock
and confirming.Locking an intercept freezes it, preventing any conditions from being added or removed in the future. This is important as other users or E2E tests may rely on intercepts having a consistent set of conditions.
Make a GET request to the same URL from earlier -
http://localhost:8080/call/foo/jsp/posts
. The response is the same, except now there is a new header -X-Interceptor-Intercept
with the ID of the triggered intercept.Add a response to the Intercept. 1. Click on
New
in the responses section 2. Add the nameEmpty array
3. Set the body to be[]
. 4. Presssubmit
Activate the response by pressing the
Activate
button beside the response, or by choosing it in the dropdown in the Activated Response column.Make that same GET request again to
http://localhost:8080/call/foo/jsp/posts
.Note that the response now matches the response you created. Additionally, the headers
X-Interceptor-Response
andX-Interceptor-Response-Source
are set. There are a few other headers - these are set by Express automatically but can be overridden.Set the activated response to
Pass through
. Make the request again. The response will be the default posts again from JSON placeholder.Click on
Change
in the User section. Create a new user with the usernamebar
.Click on the user name.
Click on the domain
jsp
.Activate the response
Empty array
. Make a GET request tohttp://localhost:8080/call/bar/jsp/posts
instead (notice the URL change to the user bar), and note that you receive the empty array response.Without changing anything in the UI, make a GET request to
`http://localhost:8080/call/foo/jsp/posts
(notice the URL change to the user foo) and notice that thefoo
user receives the passthrough response.
Last updated
Was this helpful?