Mercurial > pub > Impl
comparison Lib/IMPL/Web/Handler/RestController.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 | 5146e17a7b76 |
children | 3d433a977e3b |
comparison
equal
deleted
inserted
replaced
205:891c04080658 | 206:c8fe3f84feba |
---|---|
19 }; | 19 }; |
20 | 20 |
21 BEGIN { | 21 BEGIN { |
22 public property root => PROP_GET | PROP_OWNERSET; | 22 public property root => PROP_GET | PROP_OWNERSET; |
23 public property contract => PROP_GET | PROP_OWNERSET; | 23 public property contract => PROP_GET | PROP_OWNERSET; |
24 public property types => PROP_GET | PROP_OWNERSET; | |
25 } | 24 } |
26 | 25 |
27 sub CTOR { | 26 sub CTOR { |
28 my ($this) = @_; | 27 my ($this) = @_; |
29 | 28 |
30 die ArgimentException->new("types") | 29 die ArgumentException->new("root") unless $this->root; |
31 if $this->types and ref $this->types ne 'HASH'; | 30 die ArgumentException->new("contract") unless $this->contract; |
32 } | 31 } |
33 | 32 |
34 sub Invoke { | 33 sub Invoke { |
35 my ($this,$action) = @_; | 34 my ($this,$action) = @_; |
36 | 35 |
46 # remove first segment since it's always empty | 45 # remove first segment since it's always empty |
47 shift @segments; | 46 shift @segments; |
48 | 47 |
49 my ($obj,$view) = (pop(@segments) =~ m/(.*?)(?:\.(\w+))?$/); | 48 my ($obj,$view) = (pop(@segments) =~ m/(.*?)(?:\.(\w+))?$/); |
50 push @segments, $obj; | 49 push @segments, $obj; |
51 | |
52 if ($this->types and my $type = $this->types->{$view}) { | |
53 $action->response->contentType($type); | |
54 } | |
55 | 50 |
56 my $res = $this->contract->Transform($this->root, { id => '' } ); | 51 my $res = $this->contract->Transform($this->root, { id => '' } ); |
57 | 52 |
58 while(@segments) { | 53 while(@segments) { |
59 my $id = shift @segments; | 54 my $id = shift @segments; |