]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Use ?format=json instead of Accept: application/json
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster.pm
index 3cb38097fb8052b76602c7bca35e62a4b58dbbf1..af1eb781135205f798ebdbb9b1e9fc98dd1922ed 100644 (file)
@@ -125,24 +125,21 @@ sub dispatch_request{
                        response_filter { return shift }
                },
 
-               sub () {
+               sub (?:format~) {
+                       my $format = lc $_{format} // '';
                        response_filter {
                                my ($r) = @_;
                                return $r if ref $r ne 'Plack::App::Gruntmaster::Response';
-                               return [200, ['Content-Type' => 'application/json', 'X-Forever' => 1], [encode 'UTF-8', encode_json $r->{params}]] if $env->{HTTP_ACCEPT} =~ m,^\s*application/json\s*$,g;
+                               return [200, ['Content-Type' => 'application/json', 'X-Forever' => 1], [encode_json $r->{params}]] if $format eq 'json';
                                my $ret = render $r->{template}, 'en', title => $r->{title}, %{$r->{params}};
                                [200, ['Content-Type' => 'text/html'], [encode 'UTF-8', $ret]]
                        },
                },
 
-               sub (/st/) {
-                       response st => 'Standings', { st => [db->standings] }
-               },
-
                sub (/st/:contest) {
                        response st => 'Standings', {
-                               st => [ db->standings($_{contest}) ],
-                               problems => [map { $_->problem } contest->contest_problems]
+                               st => [ contest->standings ],
+                               problems => [map { $_->problem } contest->contest_problems],
                        }
                },
 
This page took 0.023784 seconds and 4 git commands to generate.