问题描述
我正在使用中间件来解析模板的输出.这对所有页面都工作正常.
I'm using a middleware to parse the output of the templates. This is working fine for all pages.
但是,当我想显示404(为此获得一个自定义页面)时,它不会将其视为http请求(这是我的想法),因为它没有通过中间件.
However when I want to show a 404 (got a custom page for that) it doesn't treat it as a http request (that's what I think) since it doesn't go through the middleware.
我的问题是,如何让所有请求都通过中间件.
My question is, how to have ALL requests go through the middleware.
推荐答案
错误页面无法通过route.php.
The error pages don't go through the routes.php.
在Kernel.php
中,将中间件从$routeMiddleware
阵列移动到$middleware
阵列.
In Kernel.php
move your middleware from the $routeMiddleware
array to $middleware
array.
此数组中的中间件将在每个请求上运行(已在5.1中进行测试).
Middleware in this array will run on every request (tested in 5.1).
这篇关于Laravel 5.0自定义404不使用中间件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!