This commit is contained in:
2020-12-16 15:40:42 +08:00
parent 18743e0003
commit 8063d3b1c3
+10 -7
View File
@@ -135,7 +135,7 @@ class Router extends Application implements RouterInterface
* @param string $method * @param string $method
* @return Node * @return Node
*/ */
private function tree($path, $handler, $method = 'any') private function tree($path, $handler, $method = 'any'): Node
{ {
list($first, $explode) = $this->split($path); list($first, $explode) = $this->split($path);
@@ -157,7 +157,7 @@ class Router extends Application implements RouterInterface
* @param $method * @param $method
* @return Node * @return Node
*/ */
private function bindNode(Node $parent, array $explode, $method) private function bindNode(Node $parent, array $explode, $method): Node
{ {
$a = 0; $a = 0;
if (empty($explode)) { if (empty($explode)) {
@@ -182,9 +182,10 @@ class Router extends Application implements RouterInterface
/** /**
* @param $route * @param $route
* @param $handler * @param $handler
* @return Node|mixed|null * @return mixed
* @throws ConfigException
*/ */
public function socket($route, $handler) public function socket($route, $handler): mixed
{ {
return $this->addRoute($route, $handler, 'socket'); return $this->addRoute($route, $handler, 'socket');
} }
@@ -193,10 +194,10 @@ class Router extends Application implements RouterInterface
/** /**
* @param $route * @param $route
* @param $handler * @param $handler
* @return mixed|Node|null * @return Node|null
* @throws * @throws ConfigException
*/ */
public function post($route, $handler) public function post($route, $handler): ?Node
{ {
return $this->addRoute($route, $handler, 'post'); return $this->addRoute($route, $handler, 'post');
} }
@@ -479,6 +480,7 @@ class Router extends Application implements RouterInterface
if (!($node = $this->find_path(\request()))) { if (!($node = $this->find_path(\request()))) {
return send(self::NOT_FOUND, 404); return send(self::NOT_FOUND, 404);
} }
var_dump($node);
send($node->dispatch(), 200); send($node->dispatch(), 200);
if ($node->hasAfter()) { if ($node->hasAfter()) {
$node->afterDispatch(\request()); $node->afterDispatch(\request());
@@ -486,6 +488,7 @@ class Router extends Application implements RouterInterface
} catch (ExitException $exception) { } catch (ExitException $exception) {
send($exception->getMessage(), $exception->getCode()); send($exception->getMessage(), $exception->getCode());
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
var_dump($exception);
send($this->exception($exception), 200); send($this->exception($exception), 200);
} }
} }