Mercurial > pub > Impl
annotate Lib/IMPL/Web/Handler/JSONView.pm @ 202:5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
author | sergey |
---|---|
date | Wed, 25 Apr 2012 02:49:23 +0400 |
parents | e743a8481327 |
children | c8fe3f84feba |
rev | line source |
---|---|
198 | 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 | |
199
e743a8481327
Added REST support for forms (with only get and post methods)
sergey
parents:
198
diff
changeset
|
20 #$action->response->contentType('text/javascript'); |
198 | 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 |