There are several ways to inform Spike of which services you want to work with and keep track of. Service definition can be easily created manually, or Spike can "auto-discover" them, as requests are proxied through Spike. Below we show how to quickly set up using auto-discover mode.
- First download and install Spike: Windows or OSX/Linux.
- On Windows, check the "Launch Spike" box in the installer, which configures Spike as the system-wide http proxy automatically, and launches the application in the background.
- For non-Windows, launch
spike.osx, with the command-line flag
-d <directory-name>, pointing at a directory to hold the Spike configuration and runtime data.
- The local web console is now running at http://localhost:9600
- Go to your client application and perform several operations that make service requests, to pass API data through Spike.
The Spike UI page will update with a yellow message bar, showing that it discovered new services. Click the link, and you'll see the API calls that passed through Spike. From that page you can approve the API URLs that should be saved as Spike services.
Now Spike knows about your service APIs. As you continue to use your client application, Spike will track statistics on these services, let you simulate failures, and let you use stored responses in the event that a backend service goes down.
Using Spike to play back stored responses
Spike automatically captures all data for the services it tracks. You can easily switch it to play back captured data instead of forwarding requests to the destination services. This lets you go offline during dev or testing, and lets you continue to work when a service goes down or acts flaky.
To play back captured data:
- In the Spike admin UI (http://localhost:9600) go to "Replay" tab.
- Click the "replay" button. Leave the default setting of "Use latest stored response."
- Return to your client application and perform whatever operations will trigger service requests. Those requests will now be answered immediately by Spike, instead of being forwarded to the destination services.
For more info on capturing data and using saved responses later, see here