Return 500 when file or index is not readable to Dexter.
This commit is contained in:
parent
453d6ab787
commit
ea4332d207
|
@ -28,6 +28,7 @@ Readonly::Hash my %MEANING_OF_HTTP_CODE => (
|
||||||
'404' => 'File Not Found',
|
'404' => 'File Not Found',
|
||||||
'409' => 'Conflict',
|
'409' => 'Conflict',
|
||||||
'413' => 'Payload Too Large',
|
'413' => 'Payload Too Large',
|
||||||
|
'500' => 'Internal Server Error',
|
||||||
);
|
);
|
||||||
|
|
||||||
Readonly my $ROOT_DIRECTORY => 'public';
|
Readonly my $ROOT_DIRECTORY => 'public';
|
||||||
|
@ -119,7 +120,19 @@ helper render_index => sub ($c) {
|
||||||
my $url = $c->req->url;
|
my $url = $c->req->url;
|
||||||
my $user = $c->req->env->{REMOTE_USER};
|
my $user = $c->req->env->{REMOTE_USER};
|
||||||
my $path = $url->path;
|
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 ) {
|
if ( not -d $ROOT_DIRECTORY . $path->to_route ) {
|
||||||
$path->trailing_slash(0);
|
$path->trailing_slash(0);
|
||||||
$path = $path->to_dir;
|
$path = $path->to_dir;
|
||||||
|
|
Loading…
Reference in New Issue