mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 18:44:17 +00:00
support load controllers
This commit is contained in:
parent
d4586801cd
commit
d80f7a3736
@ -44,6 +44,7 @@ class Server {
|
|||||||
this.routes = []
|
this.routes = []
|
||||||
this.endpoints = {}
|
this.endpoints = {}
|
||||||
this.middlewares = []
|
this.middlewares = []
|
||||||
|
this.controllers = { ...this.params.controllers }
|
||||||
this.headers = { ...defaultHeaders, ...this.params.headers }
|
this.headers = { ...defaultHeaders, ...this.params.headers }
|
||||||
|
|
||||||
//* set server basics
|
//* set server basics
|
||||||
@ -174,8 +175,13 @@ class Server {
|
|||||||
|
|
||||||
// check if controller is an already a controller
|
// check if controller is an already a controller
|
||||||
if (typeof controller === "string") {
|
if (typeof controller === "string") {
|
||||||
|
// check if the controller is already loaded, else try to fetch
|
||||||
|
if (typeof this.controllers[controller] !== "undefined") {
|
||||||
|
controller = this.controllers[controller]
|
||||||
|
} else {
|
||||||
controller = fetchController(controller)
|
controller = fetchController(controller)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if the controller is an default function and transform it into an controller
|
// check if the controller is an default function and transform it into an controller
|
||||||
if (typeof controller === "function") {
|
if (typeof controller === "function") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user