|
|
Restify comes bundled with a selection of useful plugins. These are accessible
|
||
|
|
off of `restify.plugins` and `restify.pre`.
|
||
|
|
|
||
|
|
```js
|
||
|
|
var server = restify.createServer();
|
||
|
|
server.use(restify.plugins.acceptParser(server.acceptable));
|
||
|
|
server.use(restify.plugins.authorizationParser());
|
||
|
|
server.use(restify.plugins.dateParser());
|
||
|
|
server.use(restify.plugins.queryParser());
|
||
|
|
server.use(restify.plugins.jsonp());
|
||
|
|
server.use(restify.plugins.gzipResponse());
|
||
|
|
server.use(restify.plugins.bodyParser());
|
||
|
|
server.use(restify.plugins.requestExpiry());
|
||
|
|
server.use(restify.plugins.throttle({
|
||
|
|
burst: 100,
|
||
|
|
rate: 50,
|
||
|
|
ip: true,
|
||
|
|
overrides: {
|
||
|
|
'192.168.1.1': {
|
||
|
|
rate: 0, // unlimited
|
||
|
|
burst: 0
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}));
|
||
|
|
server.use(restify.plugins.conditionalRequest());
|