diff Lib/IMPL/Web/Handler/JSONView.pm @ 233:3cebcf6fdb9b

refactoring, cleaning code
author sergey
date Thu, 11 Oct 2012 04:53:08 +0400
parents c8fe3f84feba
children f48a1a9f4fa2
line wrap: on
line diff
--- a/Lib/IMPL/Web/Handler/JSONView.pm	Tue Oct 09 20:12:47 2012 +0400
+++ b/Lib/IMPL/Web/Handler/JSONView.pm	Thu Oct 11 04:53:08 2012 +0400
@@ -2,13 +2,15 @@
 use strict;
 use JSON;
 
-use IMPL::lang qw(:declare :constants);
 use IMPL::declare {
-	base => {
+    require => {
+        HttpResponse => 'IMPL::Web::HttpResponse'        
+    },
+	base => [
 		'IMPL::Object' => undef,
 		'IMPL::Object::Serializable' => undef,
 		'IMPL::Object::Autofill' => '@_'
-	}
+	]
 };
 
 sub contentType {
@@ -23,9 +25,11 @@
 	
 	$action->response->contentType($this->contentType);
     
-    my $hout = $action->response->streamBody;
-    
-    print $hout JSON->new->utf8->pretty->encode($result);
+    return HttpResponse->new({
+        type => $this->contentType,
+        charset => 'utf-8',             
+        body => JSON->new->utf8->pretty->encode($result)
+    });
 }
 
 1;