Project configuration
netsleuth supports automatic project configuration so that the developers on your team can start using netsleuth with zero configuration required.
Create a file called .sleuthrc
in your project's root folder. This JSON file should have the following properties:
project
- the project's nameinspect
- an array of targets to create when this project runstarget
- the HTTP server that requests should be sent tohost
- the hostname to request from the public gateway.{user}
will be replaced with the logged in username.serviceOpts
- public gateway options — see APIlocal
- iftrue
, the inspector will be created in local proxy mode instead of public gateway mode.
Example
{ "project": "test-project", "inspect": [ { "target": "http://localhost:5000", "host": "test-{user}", "serviceOpts": { "store": true } }, { "target": "http://localhost:5000", "local": true } ] }
Integrating with node.js projects
Once your .sleuthrc
file is set up, add netsleuth to your project as a development dependency.
npm install --save-dev netsleuth
Then use the API in your dev server as the very first thing your app does:
if (process.env.NODE_ENV == 'dev') { var netsleuth = require('netsleuth'); netsleuth.attach('test-project'); }
This will:
- Start the daemon if it is not already running, and
- Hook the node.js process so that you can inspect requests outgoing from it, and
- It will process the
.sleuthrc
and add new targets to the developer's netsleuth configuration as necessary.
Integrating with non-node.js projects
The netsleuth CLI has a command that runs the autoconfiguration process. If you have a build process, you can simply add netsleuth project
as a build task to ensure that netsleuth is ready to use.