| @@ 43-60 (lines=18) @@ | ||
| 40 | * @param RequestHandlerInterface $handler Request handler |
|
| 41 | * @return ResponseInterface |
|
| 42 | */ |
|
| 43 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface |
|
| 44 | { |
|
| 45 | ||
| 46 | $response = $handler->handle($request); |
|
| 47 | ||
| 48 | // Now that all is done, |
|
| 49 | // concat to a string and send it to the PSR-3 Logger. |
|
| 50 | $status = $response->getStatusCode(); |
|
| 51 | $reason = $response->getReasonPhrase(); |
|
| 52 | ||
| 53 | $msg = sprintf("%s %s", $status, $reason); |
|
| 54 | ||
| 55 | $this->logger->info("Response", [ |
|
| 56 | 'status' => $msg |
|
| 57 | ]); |
|
| 58 | ||
| 59 | return $response; |
|
| 60 | } |
|
| 61 | ||
| 62 | ||
| 63 | ||
| @@ 73-92 (lines=20) @@ | ||
| 70 | * |
|
| 71 | * @return ResponseInterface |
|
| 72 | */ |
|
| 73 | public function __invoke( ServerRequestInterface $request, ResponseInterface $response, callable $next ) |
|
| 74 | { |
|
| 75 | // Do nothing before $next, |
|
| 76 | // instead call $next first. |
|
| 77 | $response = $next($request, $response); |
|
| 78 | ||
| 79 | ||
| 80 | // Now that all is done, |
|
| 81 | // concat to a string and send it to the PSR-3 Logger. |
|
| 82 | $status = $response->getStatusCode(); |
|
| 83 | $reason = $response->getReasonPhrase(); |
|
| 84 | ||
| 85 | $msg = sprintf("%s %s", $status, $reason); |
|
| 86 | ||
| 87 | $this->logger->info("Response", [ |
|
| 88 | 'status' => $msg |
|
| 89 | ]); |
|
| 90 | ||
| 91 | return $response; |
|
| 92 | } |
|
| 93 | ||
| 94 | } |
|
| 95 | ||