[英]How can i make sure middleware is run before another
Hi have a middleware that i must ensure is run after the auth middleware.嗨,有一个中间件,我必须确保在 auth 中间件之后运行。 How can i guarantee that the auth middleware is processed before mine?
我如何保证 auth 中间件在我之前处理? Is this even possible?
这甚至可能吗?
Thanks in advance.提前致谢。
from the laravel 5.4 documentation:来自 laravel 5.4 文档:
Route::get('/', function () {
//
})->middleware('first', 'second');
First and second must be route middleware, if you look in app/Http/Kernel.php you can find them.第一个和第二个必须是路由中间件,如果你查看 app/Http/Kernel.php 你可以找到它们。
Your middlware will be run after, Auth middleware have a higher priority.您的中间件将在之后运行,Auth 中间件具有更高的优先级。 See variable $middlewarePriority of your Kernel base class (Illuminate\\Foundation\\Http\\Kernel).
查看内核基类 (Illuminate\\Foundation\\Http\\Kernel) 的变量 $middlewarePriority。
First middleware is StartSession and this is what we want.第一个中间件是 StartSession,这就是我们想要的。
If you want, you can modify this variable to run one of your middleware before Auth.如果需要,您可以修改此变量以在 Auth 之前运行您的中间件之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.