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(設(shè)置閾值)**

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

如果客戶端請求超過了限制,服務(wù)器會返回429錯誤
 [Too Many Requests](http://tools.ietf.org/html/draft-nottingham-http-new-status-03#section-4)


| **Name**        | **Type**| **Description**|
| ------------- |:-------------:| -----:|
|rate|Number|每秒請求次數(shù)|
|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|

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,545評論 19 139
  • 感謝提供照片小伙伴,芳芳芳,陽仔,老馮和魚桀
    oli_yang閱讀 367評論 0 0
  • 其實這兩天不淡定,一是終于收到心儀公司的Offer,爸媽為之而欣慰。二是有些情緒化,很想發(fā)脾氣。 總的來說開心還是...
    見夏知曉閱讀 1,105評論 0 1
  • 文/張又可 節(jié)選自張又可散文集《青春的遺囑》 我和她在臺上翩翩起舞,她小碎花裙,紅撲撲的腮紅,倆小辮子,時而掩面哭...
    張又可閱讀 349評論 0 0
  • 瓶頸的喻意一般是指在處理問題時遇到了困難,或某種狀態(tài)遇到了阻礙,通過攻關(guān)可以解決。 比如工作瓶頸。很多...
    鹿鳴閣主閱讀 680評論 3 1

友情鏈接更多精彩內(nèi)容