是否可以在中间件函数中获取请求方法(GET,POST,PUT,...)?
$myMiddleware = function (Request $request) {
// This is what I want to achieve
switch ($request->request->get('method') {
case 'GET':
// ...
break;
}
}
$app = new Application();
$app->before($myMiddleware);
答案 0 :(得分:7)
感谢putvande。 简单如下:
$request->getMethod();