comparison Lib/IMPL/Web/Handler/JSONView.pm @ 198:2ffe6f661605

Implemented IMPL::Web::Handler::RestController fixes in IMPL::Serialization completed IMPL::Web::Application::RestResource added IMPL::Web::Handler::JSONView added IMPL::Web::RestContract
author cin
date Fri, 20 Apr 2012 16:06:36 +0400
parents
children e743a8481327
comparison
equal deleted inserted replaced
197:6b1dda998839 198:2ffe6f661605
1 package IMPL::Web::Handler::JSONView;
2 use strict;
3 use JSON;
4
5 use IMPL::lang qw(:declare :constants);
6 use IMPL::declare {
7 base => {
8 'IMPL::Object' => undef,
9 'IMPL::Object::Serializable' => undef,
10 'IMPL::Object::Autofill' => '@_'
11 }
12 };
13
14 sub Invoke {
15 my ($this,$action,$next) = @_;
16
17 my $result = $next->($action);
18 $result = [$result] unless ref $result;
19
20 $action->response->contentType('text/javascript');
21
22 my $hout = $action->response->streamBody;
23
24 print $hout JSON->new->utf8->pretty->encode($result);
25 }
26
27 1;
28
29 __END__
30
31 =pod
32
33 =head1
34
35 =cut