Mercurial > pub > Impl
comparison Lib/IMPL/Web/Handler/JSONView.pm @ 206:c8fe3f84feba
+IMPL::Web::Handlers::ViewSelector
+IMPL::Web::Handlers::ErrorHandler
*IMPL::Web::Handlers::RestController moved types mappings to ViewSelector
author | sergey |
---|---|
date | Thu, 03 May 2012 16:48:39 +0400 |
parents | e743a8481327 |
children | 3cebcf6fdb9b |
comparison
equal
deleted
inserted
replaced
205:891c04080658 | 206:c8fe3f84feba |
---|---|
9 'IMPL::Object::Serializable' => undef, | 9 'IMPL::Object::Serializable' => undef, |
10 'IMPL::Object::Autofill' => '@_' | 10 'IMPL::Object::Autofill' => '@_' |
11 } | 11 } |
12 }; | 12 }; |
13 | 13 |
14 sub contentType { | |
15 'application/json' | |
16 } | |
17 | |
14 sub Invoke { | 18 sub Invoke { |
15 my ($this,$action,$next) = @_; | 19 my ($this,$action,$next) = @_; |
16 | 20 |
17 my $result = $next->($action); | 21 my $result = $next ? $next->($action) : undef; |
18 $result = [$result] unless ref $result; | 22 $result = [$result] unless ref $result; |
19 | 23 |
20 #$action->response->contentType('text/javascript'); | 24 $action->response->contentType($this->contentType); |
21 | 25 |
22 my $hout = $action->response->streamBody; | 26 my $hout = $action->response->streamBody; |
23 | 27 |
24 print $hout JSON->new->utf8->pretty->encode($result); | 28 print $hout JSON->new->utf8->pretty->encode($result); |
25 } | 29 } |