fix(request) body parsing

This commit is contained in:
Benjamin Wegener
2024-03-18 16:27:30 +00:00
parent 2777f4763d
commit f303b67409
2 changed files with 7 additions and 5 deletions

View File

@@ -1,21 +1,22 @@
import RequestParser from '../Utils/RequestParser';
export default class LayRequest extends Request {
body = null;
body = undefined;
nativeRequest = null;
constructor(req) {
super(req);
this.params = new Map();
this.query = new Map();
this.parseBody(req);
this.nativeReq = req;
}
header(key) {
this.headers?.get(key);
}
async parseBody(req) {
this.body = await RequestParser(req);
async parseBody() {
if(typeof this.body != 'undefined') return this.body;
this.body = await RequestParser(this.nativeReq);
}
}

View File

@@ -109,6 +109,7 @@ export default class Router {
}
try {
await reqContext.request.parseBody();
const retVal = await handle.callback(
reqContext.request,
reqContext.response