This commit is contained in:
2020-09-04 18:49:36 +08:00
parent b2bc8e3726
commit 04ed73b902
2 changed files with 7 additions and 36 deletions
+7 -10
View File
@@ -49,16 +49,13 @@ class Middleware
*/ */
public function getGenerate($node) public function getGenerate($node)
{ {
foreach ($node->handler as $key => $value) { $last = function ($passable) use ($node) {
$last = function ($passable) use ($node) { return Dispatch::create($node->handler, $passable)->dispatch();
return Dispatch::create($node->handler, $passable)->dispatch(); };
}; $middleWares = $this->annotation($node);
$middleWares = $this->annotation($node); $data = array_reduce(array_reverse($middleWares), $this->core(), $last);
$data = array_reduce(array_reverse($middleWares), $this->core(), $last); $this->middleWares = [];
$this->middleWares = []; return $node->callback = $data;
$node->callback[$key] = $data;
}
return $node;
} }
-26
View File
@@ -100,32 +100,6 @@ class Router extends Application implements RouterInterface
} }
/**
* @param $route
* @param $handler
* @param int $port
* @return Node|mixed|null
*/
public function gRpc($route, $handler, $port = 33007)
{
$route = ltrim($route, '/');
if (!empty($port)) {
$route = $port . '/' . $route;
}
return $this->addRoute($route, $handler, 'grpc');
}
/**
* @param $route
* @param $handler
* @return Node|mixed|null
*/
public function task($route, $handler)
{
return $this->addRoute($route, $handler, 'Task');
}
/** /**
* @param $route * @param $route
* @param $handler * @param $handler