mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 18:44:17 +00:00
getContext support
This commit is contained in:
parent
c9d191d974
commit
a1428c55bc
@ -21,9 +21,14 @@ class Bridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateRouteDispatcher(bridge, method, route) {
|
function generateRouteDispatcher(bridge, method, route, getContext) {
|
||||||
return async function (body, query,...context){
|
return async function (body, query,...context){
|
||||||
let obj = Object()
|
let obj = Object()
|
||||||
|
|
||||||
|
if (getContext === "function") {
|
||||||
|
context = {...context, getContext()}
|
||||||
|
}
|
||||||
|
|
||||||
const response = await bridge.instance({
|
const response = await bridge.instance({
|
||||||
method: method,
|
method: method,
|
||||||
url: route,
|
url: route,
|
||||||
@ -39,7 +44,7 @@ function generateRouteDispatcher(bridge, method, route) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createInterface(address) {
|
async function createInterface(address, getContext) {
|
||||||
let objects = {
|
let objects = {
|
||||||
get: Object(),
|
get: Object(),
|
||||||
post: Object(),
|
post: Object(),
|
||||||
@ -78,7 +83,7 @@ async function createInterface(address) {
|
|||||||
nameKey = "index"
|
nameKey = "index"
|
||||||
}
|
}
|
||||||
|
|
||||||
objects[method][nameKey] = generateRouteDispatcher(bridge, method, route)
|
objects[method][nameKey] = generateRouteDispatcher(bridge, method, route, getContext)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user