我刚刚开始学习 lumen 微框架并且遇到了麻烦,因为我的中间件似乎不起作用。这是我的代码。
//defined middleware in route
$app->get('/hello/{name}', ['middleware' => 'shield','uses' => 'Sampcontroller@show']);
//registered middleware in app.php
$app->routeMiddleware([
'shield' => App\Http\Middleware\Agemiddleware::class,
]);
这是中间件代码
public function handle($request, Closure $next){
if ($request->input('name') == "18") {
echo "hate yew";
}
return $next($request);
}
}