mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 10:34:17 +00:00
comments over registerHTTPEndpoint
This commit is contained in:
parent
9b21671be8
commit
70e319665a
@ -174,16 +174,19 @@ class Server {
|
|||||||
endpoint.method = FixedMethods[endpoint.method]
|
endpoint.method = FixedMethods[endpoint.method]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// grab the middlewares
|
||||||
let middlewares = [...execs]
|
let middlewares = [...execs]
|
||||||
|
|
||||||
if (endpoint.middlewares) {
|
if (endpoint.middlewares) {
|
||||||
middlewares = [...middlewares, ...this.resolveMiddlewares(endpoint.middlewares)]
|
middlewares = [...middlewares, ...this.resolveMiddlewares(endpoint.middlewares)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure method has root object on endpointsMap
|
||||||
if (typeof this.endpointsMap[endpoint.method] !== "object") {
|
if (typeof this.endpointsMap[endpoint.method] !== "object") {
|
||||||
this.endpointsMap[endpoint.method] = {}
|
this.endpointsMap[endpoint.method] = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extend to map
|
||||||
this.endpointsMap[endpoint.method] = {
|
this.endpointsMap[endpoint.method] = {
|
||||||
...this.endpointsMap[endpoint.method],
|
...this.endpointsMap[endpoint.method],
|
||||||
[endpoint.route]: {
|
[endpoint.route]: {
|
||||||
@ -192,6 +195,7 @@ class Server {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set handler
|
||||||
this.httpInterface[endpoint.method](endpoint.route, ...middlewares, this.handleHTTPRequest)
|
this.httpInterface[endpoint.method](endpoint.route, ...middlewares, this.handleHTTPRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user