Skip to content
Commits on Source (2)
......@@ -289,7 +289,8 @@ sub startup {
$r->get('/')->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' );
......
......@@ -469,7 +469,12 @@ sub handle_request {
# (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
# intended.
if ( $template eq 'marudor' ) {
if (
$template eq 'marudor'
or ( $self->req->headers->accept
and $self->req->headers->accept eq 'application/json' )
)
{
$template = 'json';
}
......@@ -1093,11 +1098,20 @@ sub station_train_details {
)->catch(
sub {
my ($errstr) = @_;
$self->render(
'landingpage',
error =>
"Keine Abfahrt von $train_no in $station gefunden: $errstr",
status => 404,
$self->respond_to(
json => {
json => {
error =>
"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;
}
......