diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-07-28 14:12:53 +0100 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2011-07-29 15:48:27 +0200 |
commit | d46bfb791497333fd232cb6b86e76e31da6e5743 (patch) | |
tree | 371c288ae36d59c40d372e27eaadb0cbb6bc4546 | |
parent | 47c38ec819fdced7c0dacf4b69d1b8a2ad92f30c (diff) |
Fix capture indices, set bodies in output.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index 6b405aaa9..147eae85b 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -65,26 +65,26 @@ http://search.cpan.org/~bobtfish/Catalyst-Manual-5.8007/lib/Catalyst/Manual/Intr sub discovery_v2 : LocalRegex('^v2/discovery.(xml|json|html)$') : Args(0) { my ( $self, $c ) = @_; - $c->stash->{format} = $c->req->captures->[1]; + $c->stash->{format} = $c->req->captures->[0]; $c->forward( 'get_discovery' ); } sub services_v2 : LocalRegex('^v2/services.(xml|json|html)$') : Args(0) { my ( $self, $c ) = @_; - $c->stash->{format} = $c->req->captures->[1]; + $c->stash->{format} = $c->req->captures->[0]; $c->forward( 'get_services' ); } sub requests_v2 : LocalRegex('^v2/requests.(xml|json|html|rss)$') : Args(0) { my ( $self, $c ) = @_; - $c->stash->{format} = $c->req->captures->[1]; + $c->stash->{format} = $c->req->captures->[0]; $c->forward( 'get_requests' ); } sub request_v2 : LocalRegex('^v2/requests/(\d+).(xml|json|html)$') : Args(0) { my ( $self, $c ) = @_; - $c->stash->{id} = $c->req->captures->[1]; - $c->stash->{format} = $c->req->captures->[2]; + $c->stash->{id} = $c->req->captures->[0]; + $c->stash->{format} = $c->req->captures->[1]; $c->forward( 'get_request' ); } @@ -346,7 +346,7 @@ sub get_requests : Private { unless ($agency =~ m/^(\d+)$/) { $c->detach( 'error', [ sprintf(_('Invalid agency_responsible value %s'), - $value[0]) + $value) ] ); } my $agencyid = $1; @@ -416,10 +416,10 @@ sub format_output : Private { my $format = $c->stash->{format}; if ('json' eq $format) { $c->res->content_type('application/json; charset=utf-8'); - $c->stash->{response} = JSON::to_json($hashref); + $c->res->body( encode_json($hashref) ); } elsif ('xml' eq $format) { $c->res->content_type('application/xml; charset=utf-8'); - $c->stash->{response} = XMLout($hashref, RootName => undef); + $c->res->body( XMLout($hashref, RootName => undef) ); } else { $c->detach( 'error', [ sprintf(_('Invalid format %s specified.'), $format) |