php Laravel Middleware路线和请求信息
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Laravel Middleware路线和请求信息相关的知识,希望对你有一定的参考价值。
<?php
namespace App\Http\Middleware;
use Closure;
class RoleAcl
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$method_name = $request->method();
dump($method_name);
//return GET
$action_method = $request->route()->getActionMethod();
dump($action_method);
//return index
$route_action = $request->route()->getAction();
dump($route_action);
/*
[
"version" => array:1 [
0 => "v1"
]
"middleware" => array:2 [
0 => "api.controllers"
1 => "auth:api"
]
"providers" => []
"scopes" => []
"before" => []
"after" => []
"conditionalRequest" => true
"uses" => "App\Http\Controllers\Api\V1\RoleController@index"
"controller" => "RoleController@index"
"namespace" => "App\Http\Controllers\Api\V1"
"where" => []
"uri" => "/api/v1/roles"
]
*/
return $next($request);
}
}
以上是关于php Laravel Middleware路线和请求信息的主要内容,如果未能解决你的问题,请参考以下文章
barryvdh/laravel-cors 不适用于我的路线
在 Laravel 中,如何在 Route::middleware 组中使用“cannot”?
Laravel 5.4 + Ajax 等于 401 未经身份验证
php.laravel.middleware
Laravel:创建资源路线会导致工匠错误
Laravel 多重身份验证 |路由中间件