mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 18:44:17 +00:00
fix get context
This commit is contained in:
parent
4f980f980f
commit
56099604eb
@ -24,18 +24,19 @@ class Bridge {
|
|||||||
function generateRouteDispatcher(bridge, method, route, getContext) {
|
function generateRouteDispatcher(bridge, method, route, getContext) {
|
||||||
return async function (body, query, ...context){
|
return async function (body, query, ...context){
|
||||||
let obj = Object()
|
let obj = Object()
|
||||||
|
let opt = {
|
||||||
if (getContext === "function") {
|
|
||||||
context = {...context, getContext()}
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await bridge.instance({
|
|
||||||
method: method,
|
method: method,
|
||||||
url: route,
|
url: route,
|
||||||
data: body,
|
data: body,
|
||||||
params: query,
|
params: query,
|
||||||
...context
|
...context
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (typeof getContext === "function") {
|
||||||
|
opt = {...opt, ...getContext()}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await bridge.instance(opt)
|
||||||
|
|
||||||
obj = response.data
|
obj = response.data
|
||||||
obj.__proto__ = response
|
obj.__proto__ = response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user