public function onEventResponse(Application $app, Response $response)
 {
     if (null === $response->getCharset()) {
         $response->setCharset($app->getParameter('charset'));
     }
     $response->prepare($app->getRequest());
 }
Пример #2
0
 public function createApplication()
 {
     $app = new Application();
     $app->match('/hello', function () {
         return 'world';
     });
     $app->match('/html', function () {
         return '<h1>title</h1>';
     });
     $app->match('/server', function () use($app) {
         $user = $app->getRequest()->server->get('PHP_AUTH_USER');
         $pass = $app->getRequest()->server->get('PHP_AUTH_PW');
         return "<h1>{$user}:{$pass}</h1>";
     });
     return $app;
 }