Restify用法

  1. RequestLogger
    Sets up a child bunyan logger with the current request id filled in, along with any other parameters you define.
restify.requestLogger({ properties: { foo: 'bar' },
 serializers: {...}
}));```
2. **Throttle(设置阈值)**

server.use(restify.throttle({
burst: 100,
rate: 50,
ip: true,
overrides: {
'192.168.1.1': {
rate: 0, // unlimited
burst: 0
}
}
}));

如果客户端请求超过了限制,服务器会返回429错误
 [Too Many Requests](http://tools.ietf.org/html/draft-nottingham-http-new-status-03#section-4)


| **Name**        | **Type**| **Description**|
| ------------- |:-------------:| -----:|
|rate|Number|每秒请求次数|
|burst|Number|If available, the amount of requests to burst to|
|ip|Boolean|Do throttling on a /32 (source IP)|
|xff|Boolean|Do throttling on a /32 (X-Forwarded-For)|
|username|Boolean|Do throttling on req.username|
|overrides|Object|Per "key" overrides|
|tokensTable|Object|Storage engine; must support put/get|
|maxKeys|Number|If using the built-in storage table, the maximum distinct throttling keys to allow at a time|

你可能感兴趣的:(Restify用法)