Mercurial > pub > Impl
diff 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 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Handler/RestController.pm Thu Apr 19 02:10:02 2012 +0400 +++ b/Lib/IMPL/Web/Handler/RestController.pm Fri Apr 20 16:06:36 2012 +0400 @@ -5,15 +5,18 @@ use IMPL::declare { require => { + HttpException => 'IMPL::Web::Exception', NotFoundException => 'IMPL::Web::NotFoundException' }, base => { 'IMPL::Object' => undef, + 'IMPL::Object::Autofill' => '@_', + 'IMPL::Object::Serializable' => undef } }; BEGIN { - public property rootResource => PROP_GET | PROP_OWNERSET; + public property root => PROP_GET | PROP_OWNERSET; public property contract => PROP_GET | PROP_OWNERSET; } @@ -29,19 +32,22 @@ my @segments = split /\//, $pathInfo; + # remove first segment since it's always empty + shift @segments; + my ($obj,$view) = (pop(@segments) =~ m/(.*?)(?:\.(\w+))?$/); $action->context->{view} = $view; - my $res = $this->rootResource; + my $res = $this->contract->Transform($this->root); while(@segments) { - $res = $res->InvokeHttpMethod('GET',shift @segments); + $res = $this->contract->Transform( $res->InvokeHttpMethod('GET',shift @segments,$action) ); die NotFoundException->new() unless $res; } - return $res->InvokeHttpMethod($method,$obj); + $res = $res->InvokeHttpMethod($method,$obj,$action); } 1;