在app / Http / Kernel.php中动态添加中间件

时间:2016-12-16 10:44:14

标签: laravel-5.2 laravel-5.3

我创建了一个中间件App\Http\Modules\Post\Middleware\Post.php,我想在服务提供商的app/Http/Kernel.php的routeMiddleware中添加它。我怎么能做到这一点?

protected $routeMiddleware = [
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
    'can' => \Illuminate\Auth\Middleware\Authorize::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class          
];

我用Google搜索并尝试了prependMiddleware,但这是针对全球中间件的吗?

0 个答案:

没有答案