【逐日一包0027】statuses

[github地点:https://github.com/ABCDdouyae…]

statuses (koa2源码依靠)

http状况码工具包

var code = status(Integer || String) 返回对应的状况码
status(403) // => 403
status('403') // => 403
status('forbidden') // => 403
status('Forbidden') // => 403
status(306) // throws, as it's not supported by node.js
status.STATUS_CODES 返回一切状况码组成的对象{‘code’:’desc’}
console.log(status.STATUS_CODES)
status.codes返回状况码组成的数组

console.log(status.codes)
var msg = status

猎取改状况吗的形貌

status['not found'] // => 404
status['Not Found'] // => 404
status.redirect

推断状况码是否是重定向 返回boolean

status.empty[200] // => undefined
status.empty[204] // => true
status.empty[304] // => true
status.empty

203,204,304返回true 不需要返回任何实体内容

status.retry

502,503,504 返回true

    原文作者:王炜
    原文地址: https://segmentfault.com/a/1190000017313492
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞