X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster.pm;h=17d198d74b976fcb95397f5e34214999365756bf;hb=cf4801bd15e923b59c8f3760c17606b8f0e3b552;hp=b84dc81db4b13bcf3ec79a3c65f18912d831233a;hpb=218bc66cb1315afabd440e89afb7f9ce26e26444;p=gruntmaster-page.git diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index b84dc81..17d198d 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -125,11 +125,12 @@ 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_json $r->{params}]] if $env->{HTTP_ACCEPT} =~ m,^\s*application/json\s*$,g; + return [200, ['Content-Type' => 'application/json'], [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]] },