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
+5 -1
View File
@@ -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));
}
}
+1 -7
View File
@@ -206,10 +206,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
public function register(string $path, string $method, Handler $handler): void
{
$this->methods[$method . '_' . $path] = $handler;
$middlewares = $this->registerMiddleware($handler->getClass(), $handler->getMethod());
if (count($middlewares) > 0) {
$handler->setMiddlewares($middlewares);
}
$handler->setMiddlewares($this->registerMiddleware($handler->getClass(), $handler->getMethod()));
}
@@ -247,9 +244,6 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
}
}
}
var_dump($class.'::'.$method. '(' . json_encode($response, JSON_UNESCAPED_UNICODE) . ')');
return $response;
}