From 9e851fb0ed7d9c68e5c447ec25d9a505dce9321a Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 23 Jun 2010 21:05:09 +0200 Subject: remove before for http methods, set content type before finish --- lib/presque/Role/Response.pm | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/presque/Role/Response.pm b/lib/presque/Role/Response.pm index 8f9aa76..a3944f3 100644 --- a/lib/presque/Role/Response.pm +++ b/lib/presque/Role/Response.pm @@ -2,27 +2,10 @@ package presque::Role::Response; use Moose::Role; -before get => sub { - (shift)->_set_response_content_type; +before finish => sub { + (shift)->response->header('Content-Type' => 'application/json'); }; -before put => sub { - (shift)->_set_response_content_type; -}; - -before post => sub { - (shift)->_set_response_content_type; -}; - -before delete => sub { - (shift)->_set_response_content_type; -}; - -sub _set_response_content_type { - my $self = shift; - $self->response->header('Content-Type' => 'application/json'); -} - sub entity { my ($self, $content) = @_; $self->finish(JSON::encode_json($content)); -- cgit v1.2.3