1 |
|
2 | Middleware
|
3 | ==========
|
4 |
|
5 | Shunter 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 |
|
7 | Shunter middleware works in the same way as Connect:
|
8 |
|
9 | ```js
|
10 | var app = shunter({});
|
11 |
|
12 | // Mount middleware on all routes
|
13 | app.use(function(request, response, next) {
|
14 | // ...
|
15 | });
|
16 |
|
17 | // Mount middleware on the /foo route
|
18 | app.use('/foo', function(request, response, next) {
|
19 | // ...
|
20 | });
|
21 |
|
22 | app.start();
|
23 | ```
|
24 |
|
25 | This 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.
|