mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 10:34:17 +00:00
added parseData option
This commit is contained in:
parent
6ca87d720a
commit
5ed0bccacd
@ -21,10 +21,11 @@ class Bridge {
|
||||
}
|
||||
}
|
||||
|
||||
function generateRouteDispatcher(bridge, method, route, getContext) {
|
||||
function generateDispatcher(bridge, method, route, getContext) {
|
||||
return async function (body, query, ...context) {
|
||||
let obj = Object()
|
||||
let opt = {
|
||||
parseData: true,
|
||||
method: method,
|
||||
url: route,
|
||||
data: body,
|
||||
@ -38,8 +39,11 @@ function generateRouteDispatcher(bridge, method, route, getContext) {
|
||||
|
||||
const req = await bridge.instance(opt)
|
||||
|
||||
if (opt.parseData) {
|
||||
obj = req.data
|
||||
obj.__proto__ = req
|
||||
}else {
|
||||
obj = req
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
@ -84,7 +88,7 @@ async function createInterface(address, getContext) {
|
||||
nameKey = "index"
|
||||
}
|
||||
|
||||
objects[method][nameKey] = generateRouteDispatcher(bridge, method, route, getContext)
|
||||
objects[method][nameKey] = generateDispatcher(bridge, method, route, getContext)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user