diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-05-15 13:08:14 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-05-15 13:08:14 +0200 |
| commit | af6ce0894094e819450764e4d035b1e9947e5cc9 (patch) | |
| tree | 1d23f095ec49be1a6733ce6db95e3ba93ef161d9 | |
| parent | add mx::role::parameterized (diff) | |
| download | presque-af6ce0894094e819450764e4d035b1e9947e5cc9.tar.gz | |
serialize to json the response
| -rw-r--r-- | lib/presque/Role/Response.pm | 29 |
1 files changed, 29 insertions, 0 deletions
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<Content-Type> header of the response to 'application/json', and serialize to L<JSON> the body. + +=head1 AUTHOR + +franck cuny E<lt>franck@lumberjaph.netE<gt> + +=head1 SEE ALSO + +=head1 LICENSE + +Copyright 2010 by Linkfluence + +L<http://linkfluence.net> + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut |
