Improvements

This commit is contained in:
David Ralph
2019-04-06 17:56:51 +01:00
parent 5709a33c23
commit c768ebc41f
9 changed files with 73 additions and 81 deletions

View File

@@ -2,15 +2,15 @@ const { parse } = require('url');
module.exports = class KirbeRequest {
constructor(req, body) {
this.url = req.url;
this.req = req;
this.body = body;
this.from = req.connection.remoteAddress;
this.method = req.method;
this.headers = req.headers;
this.parsedUrl = parse(this.url, true);
this.url = req.url;
this.req = req;
this.body = body;
this.from = req.connection.remoteAddress;
this.method = req.method;
this.headers = req.headers;
this.parsedUrl = parse(this.url, true);
}
json() { return JSON.parse(this.body); }
query (name) { return this.parsedUrl.query[name]; }
json() { return JSON.parse(this.body); }
query (name) { return this.parsedUrl.query[name]; }
};