modify
This commit is contained in:
@@ -264,7 +264,7 @@ class Router extends HttpService implements RouterInterface
|
||||
public function any($route, $handler): Any
|
||||
{
|
||||
$nodes = [];
|
||||
foreach (['get', 'post', 'options', 'put', 'delete'] as $method) {
|
||||
foreach (['get', 'post', 'options', 'put', 'delete', 'head'] as $method) {
|
||||
$nodes[] = $this->addRoute($route, $handler, $method);
|
||||
}
|
||||
return new Any($nodes);
|
||||
@@ -281,6 +281,19 @@ class Router extends HttpService implements RouterInterface
|
||||
return $this->addRoute($route, $handler, 'delete');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
* @param $handler
|
||||
* @return \HttpServer\Route\Node|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function head($route, $handler): ?Node
|
||||
{
|
||||
return $this->addRoute($route, $handler, 'head');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
* @param $handler
|
||||
@@ -493,7 +506,7 @@ class Router extends HttpService implements RouterInterface
|
||||
{
|
||||
$node = $this->find_path(\request());
|
||||
if (!($node instanceof Node)) {
|
||||
throw new RequestException(self::NOT_FOUND,404);
|
||||
throw new RequestException(self::NOT_FOUND, 404);
|
||||
}
|
||||
send(($response = $node->dispatch()), 200);
|
||||
if (!$node->hasAfter()) {
|
||||
|
||||
Reference in New Issue
Block a user