lumenweb.php中定义路由,post方法提交age参数,经过中间件auth_age:$app->group(['middleware'=>'auth_age'],function()use($app){$app->group(['namespace'=>'\App\Account\Http\Controllers'],function()use($app){$app->post('/age',['as'=>'age','uses'=>'UserController@getAge']);});});app.php中已注册auth_age:$app->routeMiddleware(['auth_age'=>App\Account\Http\Middleware\AgeMiddleware::class,]);中间件AgeMiddleware.php:publicfunctionhandle($request,Closure$next){//echo$request->input('age');exit;//post到这里能获取到if($request->input('age')<18){returnredirect('/');}return$next($request);//这里跳转到UserController@getAge}UserController.phppublicfunctiongetAge($age)//这里的$age参数无法获取,且报错{return"ageis".$age.".";}不加$age参数的话没有出错信息publicfunctiongetAge(){...}请教的问题:如何把post后的参数经过中间件,也能完整的传给后面的Controller?
慕侠2389804
江户川乱折腾
相关分类