/**
 * 执行应用程序
 * @param Request $request
 * @return mixed
 */
protected function runWithRequest(Request $request)
{
    $this->initialize();

    // 加载全局中间件
    $this->loadMiddleware();

    // 设置开启事件机制
    $this->app->event->withEvent($this->app->config->get('app.with_event', true));

    // 监听HttpRun
    $this->app->event->trigger(HttpRun::class);

   //实例化管道类同时会将中间件类转化为闭包推入队列中
    return $this->app->middleware->pipeline()
        ->send($request)
        ->then(function ($request) {
            return $this->dispatchToRoute($request);
        });
}

 

THINKPHP6 实现中间件

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-03-24
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
猜你喜欢
  • 2021-11-29
  • 2021-10-15
  • 2022-12-23
  • 2021-09-17
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案