mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 10:34: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){
|
||||
let obj = Object()
|
||||
|
||||
if (getContext === "function") {
|
||||
context = {...context, getContext()}
|
||||
}
|
||||
|
||||
const response = await bridge.instance({
|
||||
method: method,
|
||||
url: route,
|
||||
@ -39,7 +44,7 @@ function generateRouteDispatcher(bridge, method, route) {
|
||||
}
|
||||
}
|
||||
|
||||
async function createInterface(address) {
|
||||
async function createInterface(address, getContext) {
|
||||
let objects = {
|
||||
get: Object(),
|
||||
post: Object(),
|
||||
@ -78,7 +83,7 @@ async function createInterface(address) {
|
||||
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