Skip to content
GitLab
Explore
Sign in
derf
db-infoscreen
Compare revisions
a85266ef8432271d988f00e83da9f5ed350f7097 to dd1b29bc9a1813bc2151635f98231213d3453e78
Commits on Source (2)
stationboard: handle accept: application/json as well
· f51b692a
Birte Kristina Friesel
authored
Apr 24, 2024
f51b692a
/z/:train/*station: fix 404 respons for JSON requests
· dd1b29bc
Birte Kristina Friesel
authored
Apr 24, 2024
dd1b29bc
Hide whitespace changes
Inline
Side-by-side
lib/DBInfoscreen.pm
View file @
dd1b29bc
...
...
@@ -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
'
);
...
...
lib/DBInfoscreen/Controller/Stationboard.pm
View file @
dd1b29bc
...
...
@@ -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
;
}
...
...