Use middleware for displaying pretty error pages

pull/9/head
Franz Liedke 2015-06-20 22:40:15 +02:00
parent a0ef02e4f6
commit 62fcc7d3f8
4 changed files with 35 additions and 1 deletions

View File

@ -21,6 +21,7 @@ $api->pipe($app->make('Flarum\Api\Middleware\LoginWithHeader'));
$api->pipe('/api', $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.api.routes')]));
// Handle errors
if (Core::inDebugMode()) {
$api->pipe(new \Franzl\Middleware\Whoops\Middleware());
} else {

View File

@ -1,5 +1,6 @@
<?php
use Flarum\Core;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Server;
@ -18,7 +19,13 @@ $flarum = new MiddlewarePipe();
$flarum->pipe($app->make('Flarum\Forum\Middleware\LoginWithCookie'));
$flarum->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$flarum->pipe('/', $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.forum.routes')]));
$flarum->pipe(new \Franzl\Middleware\Whoops\Middleware());
// Handle errors
if (Core::inDebugMode()) {
$flarum->pipe(new \Franzl\Middleware\Whoops\Middleware());
} else {
$flarum->pipe(new \Flarum\Forum\Middleware\HandleErrors(base_path('error')));
}
$server = Server::createServer(
$flarum,

13
system/error/404.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>404 Not Found</h1>
<p>Looks like this page could not be found.</p>
</body>
</html>

13
system/error/500.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>500 Internal Server Error</h1>
<p>Something went wrong on our server.</p>
</body>
</html>