简体   繁体   English

我如何确保中间件在另一个之前运行

[英]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.

相关问题 如何在表单提交之前确保用户插入说明或文件? - How can I make sure a user either inserted a description or file before form submission? 如何确保在页面加载之前显示背景图像? - How can I make sure a background image displays before the page loads? 如何管理ftp,以确保替换了另一个文件? - How Can I manage ftp so I make sure I replace another file? 如何确保PDO的lastInsertId()不是另一个同时插入的? - How can I make sure that PDO's lastInsertId() is not that of another simultaneous insert? 如何确保随机选择的两行彼此不同? - How can I make sure that two rows selected at random are different from one another? 如何在中间件之前运行 Laravel 路由约束? - How to Run Laravel Route Constrains Before Middleware? 如何在用户单击另一个链接之前确保PHP中的功能完成? - How to make sure a function in PHP finishes before the user clicks on another link? 如何确保对服务器的请求来源合法? - how can I make sure that the origin of the request to my server is legit? Yii2:如何确保会话始终启动? - Yii2: how can I make sure session is always started? 我怎样才能拥有一系列电子邮件并确保它们都发送? - How can I have an array of emails and make sure they all send?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM