Comparing version 5.0.0-beta-3.0 to 5.0.0-beta-4.0
# restify Changelog | ||
## 5.0.0 | ||
- #1256 add `req.id()` method, Alex Liu | ||
- #1251 add `req.connectionState()` method, Alex Liu | ||
@@ -5,0 +6,0 @@ - #1250 add `server.unfinishedRequests()` method, Alex Liu |
@@ -221,2 +221,3 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved. | ||
Request.prototype.getId = function getId() { | ||
if (this._id !== undefined) { | ||
@@ -230,5 +231,20 @@ return (this._id); | ||
}; | ||
Request.prototype.id = Request.prototype.getId; | ||
Request.prototype.id = function id(reqId) { | ||
var self = this; | ||
if (reqId) { | ||
if (self._id) { | ||
throw new Error('request id is immutable, cannot be set again!'); | ||
} else { | ||
assert.string(reqId, 'reqId'); | ||
self._id = reqId; | ||
return self._id; | ||
} | ||
} | ||
return self.getId(); | ||
}; | ||
/** | ||
@@ -235,0 +251,0 @@ * retrieves the cleaned up url path. |
@@ -251,4 +251,2 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved. | ||
* @param {Object} options an options object | ||
* @param {Array} [options.reqIdHeaders] an array of request id headers to | ||
* re-use from incoming requests | ||
*/ | ||
@@ -260,3 +258,2 @@ function Server(options) { | ||
assert.string(options.name, 'options.name'); | ||
assert.optionalArrayOfString(options.reqIdHeaders, 'options.reqIdHeaders'); | ||
@@ -279,7 +276,2 @@ var self = this; | ||
var defaultReqIdHeaders = ['request-id', 'x-request-id']; | ||
this.reqIdHeaders = (options.reqIdHeaders) ? | ||
options.reqIdHeaders.concat(defaultReqIdHeaders) : | ||
defaultReqIdHeaders; | ||
var fmt = mergeFormatters(options.formatters); | ||
@@ -1129,15 +1121,2 @@ this.acceptable = fmt.acceptable; | ||
res.version = self.router.versions[self.router.versions.length - 1]; | ||
// GH-1086: set request id based on array of headers, lowest index | ||
// is highest priority. | ||
var i = 0; | ||
for (i = 0; i < self.reqIdHeaders.length; i++) { | ||
var idName = self.reqIdHeaders[i]; | ||
if (req.headers.hasOwnProperty(idName) && req.headers[idName]) { | ||
req._id = req.headers[idName]; | ||
break; | ||
} | ||
} | ||
}; | ||
@@ -1144,0 +1123,0 @@ |
@@ -47,3 +47,3 @@ { | ||
"description": "REST framework", | ||
"version": "5.0.0-beta-3.0", | ||
"version": "5.0.0-beta-4.0", | ||
"repository": { | ||
@@ -50,0 +50,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159045
3356