在Laravel中间件中显示请求方法(GET,POST,..)

Display request method (GET,POST, ..) in Laravel middleware

我在 Laravel 中有一个中间件 class,我想获取像 (GET, POST, DELETE, PUT,...) 这样的操作名称来记录信息.我有以下代码:

public function handle($request, Closure $next)
{
    $api_key = $request->headers->get('x-api-key');
    if($api_key!=$this->auth_key){
        return $this->response->unauthorize(
            "You're not authorize to access. Make sure that you're passing your api Key"
        );
    }
    return $next($request);
}

我有这条线$request->route();这可能有帮助,但我不知道该方法。

use Illuminate\Routing\Route;

private $route;

public __construct(Route $route) {
  $this->route = $route;
}

public function handle($request, Closure $next)
{
    $action = $this->route->getMethods(); // return array

    $api_key = $request->headers->get('x-api-key');
    if($api_key!=$this->auth_key){
        return $this->response->unauthorize(
            "You're not authorize to access. Make sure that you're passing your api Key"
        );
    }
    return $next($request);
}