Kernel.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http;
  3. use Illuminate\Foundation\Http\Kernel as HttpKernel;
  4. /**
  5. * Http请求核心
  6. * @property array $middleware 全局中间件
  7. * @property array $middlewareGroups 中间分组
  8. * @property array $routeMiddleware 路由中间件
  9. *
  10. */
  11. class Kernel extends HttpKernel
  12. {
  13. /**
  14. * 全局HTTP中间件堆栈
  15. *
  16. * 这些中间件在应用程序的每个请求期间都会运行.
  17. *
  18. * @var array
  19. */
  20. protected $middleware = [
  21. // 获取应该信任的主机
  22. // \App\Http\Middleware\TrustHosts::class,
  23. // 关于设置信任代理有关的中间件
  24. //\App\Http\Middleware\TrustProxies::class,
  25. // 设置跨域请求 config/cors.php 可配置
  26. \Fruitcake\Cors\HandleCors::class,
  27. // post数据大小
  28. \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
  29. // 修剪字符串
  30. \App\Http\Middleware\TrimStrings::class,
  31. // 将空字符串字段转换为 null
  32. \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
  33. // 读取语言环境
  34. \App\Http\Middleware\LoadLocale::class,
  35. ];
  36. /**
  37. * 应用程序的路由中间件组
  38. *
  39. * 这些中间件在应用程序的每个路由分组请求期间都会运行.
  40. * @var array
  41. */
  42. protected $middlewareGroups = [
  43. 'api' => [
  44. // 动态路由绑定
  45. \Illuminate\Routing\Middleware\SubstituteBindings::class,
  46. // 先验证登录
  47. \App\Http\Middleware\Company\Login::class,
  48. ],
  49. ];
  50. /**
  51. * 应用程序的路由中间件
  52. *
  53. * 这些中间件可以分配给组或单独使用
  54. *
  55. * @var array
  56. */
  57. protected $routeMiddleware = [
  58. ];
  59. }