This commit is contained in:
2025-12-30 20:21:44 +08:00
parent 01ad7d7416
commit ea3eacdb84
2 changed files with 14 additions and 16 deletions
+9 -5
View File
@@ -37,7 +37,7 @@ class Router
/**
* @param string $name
* @param string $name
* @param Closure $closure
*/
public static function addServer(string $name, Closure $closure): void
@@ -150,8 +150,8 @@ class Router
/**
* @param array|RequestMethod $methods
* @param string $route
* @param string|array $handler
* @param string $route
* @param string|array $handler
*/
public static function addRoute(array|RequestMethod $methods, string $route, string|array $handler): void
{
@@ -164,7 +164,7 @@ class Router
/**
* @param array $config
* @param array $config
* @param Closure $closure
*
* @throws
@@ -211,11 +211,15 @@ class Router
foreach ($router->getMethods() as $name => $method) {
$middlewares = $method->getMiddlewares();
$validator = MiddlewareManager::getValidator($method->getClass(), $method->getMethod());
var_dump(sprintf("%s::%s(%s)", $method->getClass(), $method->getMethod(), json_encode($middlewares, JSON_UNESCAPED_UNICODE)));
if (!is_null($validator)) {
array_unshift($middlewares, new ValidatorMiddleware(di(ResponseInterface::class), $method->getClass(), $method->getMethod()));
}
// var_dump(sprintf("%s::%s(%s)",$method->getClass(), $method->getMethod(), json_encode($middlewares,JSON_UNESCAPED_UNICODE)));
$router->setHttpHandler($name, new HttpRequestHandler($middlewares, $method));
}
}