This commit is contained in:
2020-09-04 18:13:06 +08:00
parent f64d402317
commit 3914fa22d9
2 changed files with 28 additions and 22 deletions
+9 -3
View File
@@ -310,9 +310,15 @@ class Node extends Application
*/
public function addMiddleware(string $class)
{
// if (in_array($class, $this->middleware)) {
// return;
// }
if (is_string($class)) {
$class = Snowflake::createObject($class);
if (!($class instanceof \HttpServer\IInterface\Middleware)) {
return;
}
$class = [$class, 'handler'];
} else if (!is_callable($class, true)) {
return;
}
$this->middleware[] = $class;
$this->restructure();
}