diff --git a/app/dexter.pl b/app/dexter.pl index efdb21a..45b2fd1 100755 --- a/app/dexter.pl +++ b/app/dexter.pl @@ -28,6 +28,7 @@ Readonly::Hash my %MEANING_OF_HTTP_CODE => ( '404' => 'File Not Found', '409' => 'Conflict', '413' => 'Payload Too Large', + '500' => 'Internal Server Error', ); Readonly my $ROOT_DIRECTORY => 'public'; @@ -119,7 +120,19 @@ helper render_index => sub ($c) { my $url = $c->req->url; my $user = $c->req->env->{REMOTE_USER}; my $path = $url->path; - + + if ( not -r $ROOT_DIRECTORY . $path->to_route ) { + $path->trailing_slash(0); + $path = $path->to_dir; + $url->path($path); + + $c->render(template => 'error', + status => '500', + message => 'Dexter cannot read that file or index!'); + + return 0; + } + if ( not -d $ROOT_DIRECTORY . $path->to_route ) { $path->trailing_slash(0); $path = $path->to_dir;