From af6ce0894094e819450764e4d035b1e9947e5cc9 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sat, 15 May 2010 13:08:14 +0200 Subject: serialize to json the response --- lib/presque/Role/Response.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/presque/Role/Response.pm b/lib/presque/Role/Response.pm index 4f0960f..8f9aa76 100644 --- a/lib/presque/Role/Response.pm +++ b/lib/presque/Role/Response.pm @@ -23,4 +23,33 @@ sub _set_response_content_type { $self->response->header('Content-Type' => 'application/json'); } +sub entity { + my ($self, $content) = @_; + $self->finish(JSON::encode_json($content)); +} + 1; +=head1 NAME + +presque::Role::Response + +=head1 DESCRIPTION + +Set the B header of the response to 'application/json', and serialize to L the body. + +=head1 AUTHOR + +franck cuny Efranck@lumberjaph.netE + +=head1 SEE ALSO + +=head1 LICENSE + +Copyright 2010 by Linkfluence + +L + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut -- cgit v1.2.3