| @@ 61-79 (lines=19) @@ | ||
| 58 | /** |
|
| 59 | * {@inheritdoc} |
|
| 60 | */ |
|
| 61 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
| 62 | { |
|
| 63 | $profile = $this->factory->createProfile(); |
|
| 64 | $profile->setPlugin($this->pluginName); |
|
| 65 | $profile->setRequest($this->formatter->formatRequest($request)); |
|
| 66 | ||
| 67 | $this->collector->getCurrentStack()->addProfile($profile); |
|
| 68 | ||
| 69 | return $this->plugin->handleRequest($request, $next, $first)->then(function (ResponseInterface $response) use ($profile) { |
|
| 70 | $profile->setResponse($this->formatter->formatResponse($response)); |
|
| 71 | ||
| 72 | return $response; |
|
| 73 | }, function (Exception $exception) use ($profile) { |
|
| 74 | $profile->setFailed(true); |
|
| 75 | $profile->setResponse($this->formatter->formatException($exception)); |
|
| 76 | ||
| 77 | throw $exception; |
|
| 78 | }); |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||
| @@ 54-72 (lines=19) @@ | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | */ |
|
| 54 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
| 55 | { |
|
| 56 | $stack = $this->factory->createStack(); |
|
| 57 | $stack->setClient($this->client); |
|
| 58 | $stack->setRequest($this->formatter->formatRequest($request)); |
|
| 59 | ||
| 60 | $this->collector->addStack($stack); |
|
| 61 | ||
| 62 | return $next($request)->then(function (ResponseInterface $response) use ($stack) { |
|
| 63 | $stack->setResponse($this->formatter->formatResponse($response)); |
|
| 64 | ||
| 65 | return $response; |
|
| 66 | }, function (Exception $exception) use ($stack) { |
|
| 67 | $stack->setResponse($this->formatter->formatException($exception)); |
|
| 68 | $stack->setFailed(true); |
|
| 69 | ||
| 70 | throw $exception; |
|
| 71 | }); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||