mirror of https://gitee.com/bigwinds/arangodb
Add req.json
This commit is contained in:
parent
7065d29975
commit
96aa1d9129
|
@ -44,6 +44,7 @@ module.exports = class SyntheticRequest {
|
|||
this.pathParams = {};
|
||||
this.queryParams = querystring.decode(this._url.query);
|
||||
this.body = getRawBodyBuffer(req);
|
||||
this.rawBody = this.body;
|
||||
|
||||
const server = extractServer(req, context.trustProxy);
|
||||
this.protocol = server.protocol;
|
||||
|
@ -145,6 +146,13 @@ module.exports = class SyntheticRequest {
|
|||
return this._raw.database;
|
||||
}
|
||||
|
||||
json() {
|
||||
if (!this.rawBody) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.parse(this.rawBody.toString('utf-8'));
|
||||
}
|
||||
|
||||
params(name) {
|
||||
if (hasOwnProperty.call(this.pathParams, name)) {
|
||||
return this.pathParams[name];
|
||||
|
|
Loading…
Reference in New Issue