UNPKG

793 BMarkdownView Raw
1
2Middleware
3==========
4
5Shunter uses [Connect](https://github.com/senchalabs/connect) under the hood and exposes Connect's `use` method to allow you to add your own middleware to the stack. The middleware that you specify gets mounted before Shunter's proxying behaviour so you're able to hijack certain routes.
6
7Shunter middleware works in the same way as Connect:
8
9```js
10var app = shunter({});
11
12// Mount middleware on all routes
13app.use(function(request, response, next) {
14 // ...
15});
16
17// Mount middleware on the /foo route
18app.use('/foo', function(request, response, next) {
19 // ...
20});
21
22app.start();
23```
24
25This allows you to expose information about Shunter's environment, or add in routes that you don't wish to hit one of the back end applications that your application proxies to.