This commit is contained in:
2021-04-21 10:27:15 +08:00
parent 294a5fccc0
commit bc6e4afe12
+6 -7
View File
@@ -3,19 +3,16 @@ declare(strict_types=1);
namespace HttpServer\Route; namespace HttpServer\Route;
use Annotation\Aspect;
use Closure; use Closure;
use Database\InjectProperty;
use Exception; use Exception;
use HttpServer\Abstracts\HttpService; use HttpServer\Abstracts\HttpService;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use HttpServer\IInterface\Middleware; use HttpServer\IInterface\Middleware;
use HttpServer\IInterface\RouterInterface; use HttpServer\IInterface\RouterInterface;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
use ReflectionException;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
use Snowflake\Core\Json; use Snowflake\Core\Json;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -331,9 +328,9 @@ class Router extends HttpService implements RouterInterface
* @param string|array $middleware * @param string|array $middleware
* @return array * @return array
* @throws NotFindClassException * @throws NotFindClassException
* @throws \ReflectionException * @throws ReflectionException
*/ */
private function resolve_middleware(string|array $middleware) private function resolve_middleware(string|array $middleware): array
{ {
if (is_string($middleware)) { if (is_string($middleware)) {
$middleware = [$middleware]; $middleware = [$middleware];
@@ -346,9 +343,11 @@ class Router extends HttpService implements RouterInterface
if (!($value instanceof Middleware)) { if (!($value instanceof Middleware)) {
continue; continue;
} }
} $array[] = [$value, 'onHandler'];
} else {
$array[] = $value; $array[] = $value;
} }
}
return $array; return $array;
} }