php-sroute icon indicating copy to clipboard operation
php-sroute copied to clipboard

添加middleware 不生效

Open aizxin opened this issue 4 years ago • 3 comments

        // Not in group
        if (!$this->currentGroupPrefix) {
            return;
        }

middleware,use 在路由中都不生效 只有在group里的单个路由才生效

// Prepend group middleware at before.
        if ($this->currentGroupChains) {
            $route->setChains(array_merge($this->currentGroupChains, $route->getChains()));
        }

数组合并是不是用问题,不知道设计是几维数组,middleware 都是一维数组嘛??

Route::use(['api'])->group('/api', function () {
    Route::get('/test', \app\controller\IndexController::class . '@index')->middleware(['api1']);
},['api2','api3']);

dump 的middleware $router->getChains()

array(3) {
  [0]=>
  string(4) "api2"
  [1]=>
  string(4) "api3"
  [2]=>
  array(1) {
    [0]=>
    string(4) "api1"
  }
}

aizxin avatar May 30 '20 09:05 aizxin

我测试检查下

inhere avatar May 31 '20 02:05 inhere

@aizxin ->middleware(['api1']) 这里写错了,该是:

->middleware('api1') 多个这样写: ->middleware('api1', 'api4', 'api5')

我加下检查限制

inhere avatar Jun 01 '20 14:06 inhere

现在的Nginx.conf配置会让导致无法获取GET参数

licat233 avatar Sep 30 '20 09:09 licat233