fix(request) body parsing
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user