123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Http;
- use Illuminate\Foundation\Http\Kernel as HttpKernel;
- /**
- * Http请求核心
- * @property Array $middleware 全局中间件
- * @property Array $middlewareGroups 中间分组
- * @property Array $routeMiddleware 路由中间件
- *
- */
- class Kernel extends HttpKernel
- {
- /**
- * 全局HTTP中间件堆栈
- *
- * 这些中间件在应用程序的每个请求期间都会运行.
- *
- * @var array
- */
- protected $middleware = [
- // 获取应该信任的主机
- // \App\Http\Middleware\TrustHosts::class,
- // 关于设置信任代理有关的中间件
- //\App\Http\Middleware\TrustProxies::class,
- // 设置跨域请求 config/cors.php 可配置
- \Fruitcake\Cors\HandleCors::class,
- // post数据大小
- \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
- // 修剪字符串
- \App\Http\Middleware\TrimStrings::class,
- // 将空字符串字段转换为 null
- \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
- // 读取语言环境
- \App\Http\Middleware\LoadLocale::class,
- ];
- /**
- * 应用程序的路由中间件组
- *
- * 这些中间件在应用程序的每个路由分组请求期间都会运行.
- * @var array
- */
- protected $middlewareGroups = [
- /* web请求 */
- 'web' => [
- // cookies加密
- \App\Http\Middleware\EncryptCookies::class,
- // 队列cookie到响应
- \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
- // 使用session 注意 一定要在cookie加密之后
- \Illuminate\Session\Middleware\StartSession::class,
- // CSRF 保护 注意 一定要在session开始之后
- \App\Http\Middleware\VerifyCsrfToken::class,
- // 替换绑定
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
- ],
- /* 接口请求 */
- 'api' => [
- // 替换绑定
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
- // 验证请求签名
- ],
- ];
- /**
- * 应用程序的路由中间件
- *
- * 这些中间件可以分配给组或单独使用
- *
- * @var array
- */
- protected $routeMiddleware = [
- // 后端登录验证
- 'admin'=>\App\Http\Middleware\AdminAuth::class,
- ];
- }
|