comparison Lib/IMPL/Web/Handler/RestController.pm @ 198:2ffe6f661605

Implemented IMPL::Web::Handler::RestController fixes in IMPL::Serialization completed IMPL::Web::Application::RestResource added IMPL::Web::Handler::JSONView added IMPL::Web::RestContract
author cin
date Fri, 20 Apr 2012 16:06:36 +0400
parents 6b1dda998839
children e743a8481327
comparison
equal deleted inserted replaced
197:6b1dda998839 198:2ffe6f661605
3 3
4 use IMPL::lang qw(:declare :constants); 4 use IMPL::lang qw(:declare :constants);
5 5
6 use IMPL::declare { 6 use IMPL::declare {
7 require => { 7 require => {
8 HttpException => 'IMPL::Web::Exception',
8 NotFoundException => 'IMPL::Web::NotFoundException' 9 NotFoundException => 'IMPL::Web::NotFoundException'
9 }, 10 },
10 base => { 11 base => {
11 'IMPL::Object' => undef, 12 'IMPL::Object' => undef,
13 'IMPL::Object::Autofill' => '@_',
14 'IMPL::Object::Serializable' => undef
12 } 15 }
13 }; 16 };
14 17
15 BEGIN { 18 BEGIN {
16 public property rootResource => PROP_GET | PROP_OWNERSET; 19 public property root => PROP_GET | PROP_OWNERSET;
17 public property contract => PROP_GET | PROP_OWNERSET; 20 public property contract => PROP_GET | PROP_OWNERSET;
18 } 21 }
19 22
20 sub Invoke { 23 sub Invoke {
21 my ($this,$action) = @_; 24 my ($this,$action) = @_;
27 #TODO: path_info is broken for IIS 30 #TODO: path_info is broken for IIS
28 my $pathInfo = $query->path_info; 31 my $pathInfo = $query->path_info;
29 32
30 my @segments = split /\//, $pathInfo; 33 my @segments = split /\//, $pathInfo;
31 34
35 # remove first segment since it's always empty
36 shift @segments;
37
32 my ($obj,$view) = (pop(@segments) =~ m/(.*?)(?:\.(\w+))?$/); 38 my ($obj,$view) = (pop(@segments) =~ m/(.*?)(?:\.(\w+))?$/);
33 39
34 $action->context->{view} = $view; 40 $action->context->{view} = $view;
35 41
36 my $res = $this->rootResource; 42 my $res = $this->contract->Transform($this->root);
37 43
38 while(@segments) { 44 while(@segments) {
39 $res = $res->InvokeHttpMethod('GET',shift @segments); 45 $res = $this->contract->Transform( $res->InvokeHttpMethod('GET',shift @segments,$action) );
40 46
41 die NotFoundException->new() unless $res; 47 die NotFoundException->new() unless $res;
42 } 48 }
43 49
44 return $res->InvokeHttpMethod($method,$obj); 50 $res = $res->InvokeHttpMethod($method,$obj,$action);
45 } 51 }
46 52
47 1; 53 1;
48 54
49 __END__ 55 __END__