/**
* Generate a New status
* @param code
* @param message
* @constructor
*/
function Status(code, message) {
this.code = code;
this.message = message;
}
Status.prototype.valueOf = function() {
return this.code;
};
Status.prototype.toString = function() {
return this.message;
};
function define(key, code, message) {
Object.defineProperty(hs, key, {
configurable: false,
enumerable: true,
get() {
return new Status(code, message);
}
});
}
define('Continue', 100, 'Continue');
define('SwitchingProtocols', 101, 'Switching Protocols');
define('Processing', 102, 'Processing');
define('OK', 200, 'OK');
define('Created', 201, 'OK');
define('Accepted', 202, 'OK');
define('NonAuthoritativeInfo', 203, 'OK');
define('NoContent', 204, 'OK');
define('ResetContent', 205, 'OK');
define('PartialContent', 206, 'OK');
define('MultiStatus', 207, 'OK');
define('AlreadyReported', 208, 'OK');
define('IMUsed', 226, 'OK');
// 100
hs.Continue = new Status(100, 'Continue');
hs.SwitchingProtocols = new Status(101, 'Switching Protocols');
hs.Processing = new Status(102, 'Processing');
// 200
hs.OK = new Status(200, 'OK');
hs.Created = new Status(201, 'Continue');
hs.Accepted = new Status(202, 'Continue');
hs.NonAuthoritativeInfo = new Status(203, 'Continue');
hs.NoContent = new Status(204, 'Continue');
hs.ResetContent = new Status(205, 'Continue');
module.exports = hs;
大牛们的评论:朕有话说
还没有人评论哦,赶紧抢沙发!