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'; import RequestParser from '../Utils/RequestParser';
export default class LayRequest extends Request { export default class LayRequest extends Request {
body = null; body = undefined;
nativeRequest = null;
constructor(req) { constructor(req) {
super(req); super(req);
this.params = new Map(); this.params = new Map();
this.query = new Map(); this.query = new Map();
this.nativeReq = req;
this.parseBody(req);
} }
header(key) { header(key) {
this.headers?.get(key); this.headers?.get(key);
} }
async parseBody(req) { async parseBody() {
this.body = await RequestParser(req); 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 { try {
await reqContext.request.parseBody();
const retVal = await handle.callback( const retVal = await handle.callback(
reqContext.request, reqContext.request,
reqContext.response reqContext.response