1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace demo\Middleware;
- use Silex\Application;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- /**
- * Finish middleware is invoked after the response has been sent.
- *
- * @package demo\Middleware
- */
- class Finish {
- /**
- * Arguments for finish() middleware are fixed, unlike those of controllers.
- *
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @param \Symfony\Component\HttpFoundation\Response $response
- * @param \Silex\Application $app
- */
- public static function handle(Request $request, Response $response, Application $app) {
- /** @var \Psr\Log\LoggerInterface $logger */
- $logger = $app['logger'];
- $path = $request->getPathInfo();
- $type = get_class($response);
- $status = $response->getStatusCode();
- // Use a warning to avoid being filtered out by the default Monolog config.
- $logger->info("Returned a $status $type on $path");
- }
- }
|