This commit is contained in:
2025-12-30 21:37:37 +08:00
parent ad56abe39d
commit dfa50c9448
2 changed files with 18 additions and 1 deletions
+17 -1
View File
@@ -289,7 +289,23 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
*/
public function query(string $path, string $method): HttpRequestHandler
{
return $this->httpHandler[$method . '_' . $path] ?? new HttpRequestHandler([], $this->found);
return $this->httpHandler[$method . '_' . $path] ?? $this->not_found_handler();
}
/**
* @return HttpRequestHandler
*/
protected function not_found_handler(): HttpRequestHandler
{
$middlewares = \config('servers.request.middlewares', []);
if (!is_array($middlewares) || count($middlewares) < 1) {
return new HttpRequestHandler($middlewares, $this->found);
}
for ($index = 0; $index < count($middlewares); $index++) {
$middlewares[$index] = \Kiri::getDi()->get($middlewares[$index]);
}
return new HttpRequestHandler($middlewares, $this->found);
}