Mercurial > pub > Impl
comparison Lib/IMPL/Web/Handler/RestController.pm @ 244:a02b110da931
refactoring
fixed binding to CGI query parameters with multiple values
author | sergey |
---|---|
date | Mon, 22 Oct 2012 04:09:27 +0400 |
parents | 3cebcf6fdb9b |
children | 827cf96faa1c |
comparison
equal
deleted
inserted
replaced
243:cd2b1f121029 | 244:a02b110da931 |
---|---|
2 use strict; | 2 use strict; |
3 | 3 |
4 use IMPL::Const qw(:prop); | 4 use IMPL::Const qw(:prop); |
5 use IMPL::declare { | 5 use IMPL::declare { |
6 require => { | 6 require => { |
7 Locator => 'IMPL::Web::AutoLocator', | |
7 ResourceInterface => 'IMPL::Web::Application::ResourceInterface', | 8 ResourceInterface => 'IMPL::Web::Application::ResourceInterface', |
8 Exception => 'IMPL::Exception', | 9 Exception => 'IMPL::Exception', |
9 ArgumentExecption => '-IMPL::InvalidArgumentException', | 10 ArgumentExecption => '-IMPL::InvalidArgumentException', |
10 NotFoundException => 'IMPL::Web::NotFoundException' | 11 NotFoundException => 'IMPL::Web::NotFoundException' |
11 }, | 12 }, |
13 'IMPL::Object' => undef, | 14 'IMPL::Object' => undef, |
14 'IMPL::Object::Autofill' => '@_', | 15 'IMPL::Object::Autofill' => '@_', |
15 'IMPL::Object::Serializable' => undef | 16 'IMPL::Object::Serializable' => undef |
16 }, | 17 }, |
17 props => [ | 18 props => [ |
18 rootResource => PROP_RO, | 19 resourceFactory => PROP_RO, |
19 trailingSlash => PROP_RO | 20 trailingSlash => PROP_RO |
20 ] | 21 ] |
21 }; | 22 }; |
22 | 23 |
23 sub CTOR { | 24 sub CTOR { |
24 my ($this) = @_; | 25 my ($this) = @_; |
25 | 26 |
26 die ArgumentException->new(rootResource => "A web-resource is required") | 27 die ArgumentException->new(resourceFactory => "A web-resource is required") |
27 unless eval { $this->rootResource->isa(ResourceInterface) }; | 28 unless $this->resourceFactory; |
29 #unless eval { $this->resourceFacotry->isa(ResourceInterface) }; | |
28 | 30 |
29 } | 31 } |
30 | 32 |
31 sub GetResourcePath { | 33 sub GetResourcePath { |
32 my ($this,$action) = @_; | 34 my ($this,$action) = @_; |
57 | 59 |
58 my $method = $action->requestMethod; | 60 my $method = $action->requestMethod; |
59 | 61 |
60 my @segments = $this->GetResourcePath($action); | 62 my @segments = $this->GetResourcePath($action); |
61 | 63 |
62 my $res = $this->rootResource; | 64 my $res = $this->resourceFactory->new( |
65 id => 'root', | |
66 location => Locator->new(base => $action->application->baseUrl) | |
67 ); | |
63 | 68 |
64 while(@segments) { | 69 while(@segments) { |
65 my $id = shift @segments; | 70 my $id = shift @segments; |
66 | 71 |
67 $res = $res->FetchChildResource($id); | 72 $res = $res->FetchChildResource($id); |