fix(request) body parsing
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ export default class Router {
|
||||
}
|
||||
|
||||
try {
|
||||
await reqContext.request.parseBody();
|
||||
const retVal = await handle.callback(
|
||||
reqContext.request,
|
||||
reqContext.response
|
||||
|
||||
Reference in New Issue
Block a user