changeset 400:ef37ec102dab

redirection support while fetching child resources
author cin
date Wed, 14 May 2014 17:27:32 +0400
parents 753e981782ce
children 16ff604298c7
files Lib/IMPL/Web/Application/HttpResponseResource.pm Lib/IMPL/Web/Application/Resource.pm
diffstat 2 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Web/Application/HttpResponseResource.pm	Wed May 14 17:27:32 2014 +0400
@@ -0,0 +1,32 @@
+package IMPL::Web::Application::HttpResponseResource;
+use strict;
+
+use IMPL::Const qw(:prop);
+use IMPL::declare {
+	require => {
+		HttpResponse => 'IMPL::Web::HttpResponse'
+	},
+	base => [
+		'IMPL::Object' => undef,
+		'IMPL::Web::Application::ResourceInterface' => undef
+	],
+	props => [
+		response => PROP_RW
+	]
+};
+
+sub CTOR {
+	my ($this,%args) = @_;
+	
+	$this->response($args{response} || HttpResponse->NoContent);
+}
+
+sub FetchChildResource {
+	return shift;
+}
+
+sub InvokeHttpVerb {
+	return shift->response;
+}
+
+1;
\ No newline at end of file
--- a/Lib/IMPL/Web/Application/Resource.pm	Mon May 12 18:04:40 2014 +0400
+++ b/Lib/IMPL/Web/Application/Resource.pm	Wed May 14 17:27:32 2014 +0400
@@ -14,10 +14,11 @@
 		OpException => '-IMPL::InvalidOperationException',
 		NotFoundException => 'IMPL::Web::NotFoundException',
 		ResourceInterface => '-IMPL::Web::Application',
+		HttpResponse => 'IMPL::Web::HttpResponse',
+		HttpResponseResource => 'IMPL::Web::Application::HttpResponseResource',
 		Loader => 'IMPL::Code::Loader'
 	},
 	base => [
-		'IMPL::Object' => undef,
 		'IMPL::Web::Application::ResourceBase' => '@_'
 	],
 	props => [
@@ -110,6 +111,12 @@
 	
 	return $info
 		if (is($info,ResourceInterface));
+		
+	$info = {
+		response => $info,
+		class => HttpResponseResource
+	}
+		if is($info,HttpResponse);
 	
 	return $this->CreateChildResource($info, $childId)
 		if ref($info) eq 'HASH';