/** * @param ServerRequestInterface $request * @param ResponseInterface $response * @param array $args * @return ResponseInterface */ public function __invoke($request, $response, $args) { $path = isset($args['pathInfo']) ? $args['pathInfo'] : ''; $info = $this->map->render($path); if (!$info->found()) { return Respond::error($request, $response)->asView(500); } if ($fp = $info->getResource()) { return Respond::view($request, $response)->asFileContents($fp, $info->getMimeType()); } return Respond::view($request, $response)->asContents($info->getContents()); }
*/ $app->get('/', function (ServerRequestInterface $request, ResponseInterface $response) { return Respond::view($request, $response)->render('index'); }); /** * */ $app->get('/info', function () { phpinfo(); exit; }); /** * check asContents */ $app->get('/content', function (Request $request, Response $response) { return Respond::view($request, $response)->asContents('<h1>Contents</h1><p>this is a string content in a layout file</p>'); }); /** * check uncaught exception */ $app->get('/throw', function () { throw new \RuntimeException('This page throws a RuntimeException!'); }); /** * jump and jumper to see the redirection and parameter in flash */ $app->group('/jump', function () { /** @var App $this */ $this->get('', JumpController::class . ':onGet'); $this->post('', JumpController::class . ':onPost'); })->add(function (Request $request, Response $response, $next) {