跳过Laravel中路由组内特定路由的中间件

时间:2016-12-12 11:26:20

标签: php laravel laravel-5

我想跳过路由组中特定路由的中间件。我怎么能这样做?

Route::group(['prefix' => 'testgroup','middleware' => ['login.oauth']],function (){
    Route :: get('/', 'testController@index');
    Route :: get('/api','testController@apiCall');
}); 

我想跳过' login.oauth' Route :: get('/api','testController@apiCall')

的中间件

2 个答案:

答案 0 :(得分:2)

Please keep that testgroup function  must be accessible to all routes and middleware function  to particular(some other route) in the same function

    Route::group(['prefix' => 'testgroup'], function () {
       Route::group(['middleware' => ['login.oauth'], function() {
        Route :: get('/', 'testController@index');
       });
       Route :: get('/api','testController@apiCall');
    });

答案 1 :(得分:1)

只需创建没有中间件的第二组:

Route::group(['prefix' => 'testgroup','middleware' => ['login.oauth']],function (){
    Route :: get('/', 'testController@index');
});

Route::group(['prefix' => 'testgroup'],function (){
    Route :: get('/api','testController@apiCall');
});