Skip to content

Commit

Permalink
闭包路由内使用request需使用依赖注入进来的,$this->request在swoole环境下是第一次注册路由时的对象
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Oct 14, 2020
1 parent 1e69d24 commit 64aa8b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/think/Route.php
Expand Up @@ -680,9 +680,9 @@ public function view(string $rule, string $template = '', array $vars = []): Rul
*/
public function redirect(string $rule, string $route = '', int $status = 301): RuleItem
{
return $this->rule($rule, function () use ($status, $route) {
return $this->rule($rule, function (Request $request) use ($status, $route) {
$search = $replace = [];
$matches = $this->request->rule()->getVars();
$matches = $request->rule()->getVars();

foreach ($matches as $key => $value) {
$search[] = '<' . $key . '>';
Expand Down

0 comments on commit 64aa8b1

Please sign in to comment.