/** * @param HttpDispatcher $dispatcher */ public function boot(HttpDispatcher $dispatcher) { $dispatcher->riseMiddleware(function (Request $request, Response $response, $next) { $start = microtime(true); /** * @var Response $response */ $response = $next($request, $response); return $response->withHeader('X-Elapsed', number_format(microtime(true) - $start, 4)); }); }
/** * @param HttpDispatcher $dispatcher * @param FactoryInterface $factory */ public function boot(HttpDispatcher $dispatcher, FactoryInterface $factory) { $dispatcher->riseMiddleware($factory->make(ProfilerWrapper::class, ['started' => microtime(true)])); }