Skip to content
Commits on Source (2)
...@@ -289,7 +289,8 @@ sub startup { ...@@ -289,7 +289,8 @@ sub startup {
$r->get('/')->to('stationboard#handle_request'); $r->get('/')->to('stationboard#handle_request');
$r->get('/multi/*station')->to('stationboard#handle_request'); $r->get('/multi/*station')->to('stationboard#handle_request');
$r->get('/*station')->to('stationboard#handle_request'); $r->get( '/*station' => [ format => [ 'html', 'json' ] ] )
->to( 'stationboard#handle_request', format => undef );
$self->types->type( json => 'application/json; charset=utf-8' ); $self->types->type( json => 'application/json; charset=utf-8' );
......
...@@ -469,7 +469,12 @@ sub handle_request { ...@@ -469,7 +469,12 @@ sub handle_request {
# (or used by) marudor.de, it was renamed to 'json'. Many clients won't # (or used by) marudor.de, it was renamed to 'json'. Many clients won't
# notice this for year to come, so we make sure mode=marudor still works as # notice this for year to come, so we make sure mode=marudor still works as
# intended. # intended.
if ( $template eq 'marudor' ) { if (
$template eq 'marudor'
or ( $self->req->headers->accept
and $self->req->headers->accept eq 'application/json' )
)
{
$template = 'json'; $template = 'json';
} }
...@@ -1093,11 +1098,20 @@ sub station_train_details { ...@@ -1093,11 +1098,20 @@ sub station_train_details {
)->catch( )->catch(
sub { sub {
my ($errstr) = @_; my ($errstr) = @_;
$self->render( $self->respond_to(
'landingpage', json => {
error => json => {
"Keine Abfahrt von $train_no in $station gefunden: $errstr", error =>
status => 404, "Keine Abfahrt von $train_no in $station gefunden: $errstr",
},
status => 404,
},
any => {
template => 'landingpage',
error =>
"Keine Abfahrt von $train_no in $station gefunden: $errstr",
status => 404,
},
); );
return; return;
} }
......