annotate Lib/IMPL/Web/Application/RestResource.pm @ 212:292226770180

bugfixes
author sergey
date Fri, 29 Jun 2012 19:24:15 +0400
parents 5146e17a7b76
children e9fd7ff3f54c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
1 package IMPL::Web::Application::RestResource;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
2 use strict;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
3
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
4 use IMPL::lang qw(:declare :constants is :hash);
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
5 use IMPL::Exception();
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
6
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
7 use IMPL::declare {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
8 require => {
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
9 ForbiddenException => 'IMPL::Web::ForbiddenException',
200
sergey
parents: 199
diff changeset
10 NotFoundException => 'IMPL::Web::NotFoundException',
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
11 InvalidOpException => '-IMPL::InvalidOperationException',
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
12 ArgumentException => '-IMPL::InvalidArgumentException',
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
13 TTransform => '-IMPL::Transform',
200
sergey
parents: 199
diff changeset
14 TResolve => '-IMPL::Config::Resolve',
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
15 CustomResource => 'IMPL::Web::Application::RestCustomResource'
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
16 },
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
17 base => {
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
18 'IMPL::Web::Application::RestCustomResource' => '@_'
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
19 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
20 };
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
21
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
22 BEGIN {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
23 public property target => PROP_GET | PROP_OWNERSET;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
24 public property index => PROP_GET | PROP_OWNERSET;
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
25 public property fetch => PROP_GET | PROP_OWNERSET;
200
sergey
parents: 199
diff changeset
26
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
27 public property methods => PROP_GET | PROP_OWNERSET;
200
sergey
parents: 199
diff changeset
28
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
29 public property childRegex => PROP_GET | PROP_OWNERSET;
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
30 public property enableForms => PROP_GET | PROP_OWNERSET;
200
sergey
parents: 199
diff changeset
31
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
32 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
33
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
34 sub CTOR {
212
292226770180 bugfixes
sergey
parents: 202
diff changeset
35 my ($this,%args) = @_;
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
36
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
37 die ArgumentException->new("target") unless $this->target;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
38
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
39 $this->final($this->childRegex ? 0 : 1);
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
40 $this->methods({}) unless $this->methods;
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
41
212
292226770180 bugfixes
sergey
parents: 202
diff changeset
42 $this->index($this->get) unless defined $this->index;
292226770180 bugfixes
sergey
parents: 202
diff changeset
43
200
sergey
parents: 199
diff changeset
44 if ($this->enableForms) {
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
45 $this->methods->{create} = {
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
46 get => $this->get,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
47 post => $this->post,
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
48 final => 1 # this resource doesn't have any children
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
49 } if $this->post;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
50
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
51 $this->methods->{edit} = {
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
52 get => $this->get,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
53 post => $this->put,
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
54 final => 1 # this resource doesn't have any children
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
55 } if $this->put;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
56
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
57 $this->methods->{delete} {
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
58 get => $this->get,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
59 post => $this->delete,
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
60 final => 1 # this resource doesn't have any children
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
61 } if $this->delete;
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
62 }
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
63 }
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
64
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
65 # создает дочерний ресурс из описания, однако все методы созданного
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
66 # ресурса переадресуются к его родителю, это нужно, чтобы публиковать
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
67 # методы и свойства объекта
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
68 sub _CreateSubResource {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
69 my ($this,$resource,$id) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
70
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
71 my %methods = map {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
72 my $method = $resource->{$_};
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
73 $_ => sub {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
74 my ($this,$action) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
75 return $this->parent->InvokeMember($method,$action);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
76 };
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
77 } grep $resource->{$_}, qw(get post put delete);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
78
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
79 return CustomResource->new(
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
80 %methods,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
81 final => $resource->{final},
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
82 parent => $this,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
83 id => $id,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
84 contract => $this->contract
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
85 );
200
sergey
parents: 199
diff changeset
86 }
sergey
parents: 199
diff changeset
87
sergey
parents: 199
diff changeset
88 sub FetchChildResource {
sergey
parents: 199
diff changeset
89 my ($this,$id,$action) = @_;
sergey
parents: 199
diff changeset
90
sergey
parents: 199
diff changeset
91 my $rx = $this->childRegex;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
92
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
93 my $res;
200
sergey
parents: 199
diff changeset
94
sergey
parents: 199
diff changeset
95 if (length $id == 0) {
sergey
parents: 199
diff changeset
96
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
97 my $method = $this->index;
200
sergey
parents: 199
diff changeset
98 die ForbiddenException->new() unless $method;
sergey
parents: 199
diff changeset
99
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
100 $res = $this->InvokeMember($method,$action);
200
sergey
parents: 199
diff changeset
101
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
102 } elsif ($this->methods and my $resource = $this->methods->{$id}) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
103
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
104 return $this->_CreateSubResource($resource,$id);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
105
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
106 } elsif ($rx and $id =~ m/^$rx$/ and my $method = $this->fetch) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
107
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
108 $method = {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
109 method => $method,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
110 parameters => 'id'
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
111 } unless ref $method;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
112
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
113 $res = $this->InvokeMember($method,$action, { id => $id } );
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
114
200
sergey
parents: 199
diff changeset
115 }
sergey
parents: 199
diff changeset
116
sergey
parents: 199
diff changeset
117 die NotFoundException->new() unless defined $res;
sergey
parents: 199
diff changeset
118
sergey
parents: 199
diff changeset
119 return $this->contract->Transform($res, {parent => $this, id => $id} );
sergey
parents: 199
diff changeset
120 }
sergey
parents: 199
diff changeset
121
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
122 sub InvokeMember {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
123 my ($this,$method,$action,$predefined) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
124
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
125 die ArgumentException->new("method","No method information provided") unless $method;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
126
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
127 #normalize method info
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
128 if (not ref $method) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
129 $method = {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
130 method => $method
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
131 };
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
132 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
133
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
134 if (ref $method eq 'HASH') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
135 my $member = $method->{method} or die InvalidOpException->new("A member name isn't specified");
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
136
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
137 $member = $member->Invoke($this) if eval { $member->isa(TResolve) };
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
138
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
139 my @args;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
140
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
141 if (my $params = $method->{parameters}) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
142 if (ref $params eq 'HASH') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
143 @args = map {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
144 $_,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
145 $this->MakeParameter($params->{$_},$action,$predefined)
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
146 } keys %$params;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
147 } elsif (ref $params eq 'ARRAY') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
148 @args = map $this->MakeParameter($_,$action,$predefined), @$params;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
149 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
150 @args = ($this->MakeParameter($params,$action,$predefined));
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
151 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
152 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
153 return $this->target->$member(@args);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
154 } elsif (ref $method eq TResolve) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
155 return $method->Invoke($this);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
156 } elsif (ref $method eq 'CODE') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
157 return $method->($this,$action);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
158 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
159 die InvalidOpException->new("Unsupported type of the method information", ref $method);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
160 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
161 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
162
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
163 sub MakeParameter {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
164 my ($this,$param,$action,$predefined) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
165
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
166 my $params = hashApply(
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
167 {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
168 id => $this->id,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
169 action => $action,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
170 query => $action->query
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
171 },
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
172 $predefined || {}
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
173 );
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
174
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
175
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
176
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
177 if ($param) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
178 if (is $param, TTransform ) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
179 return $param->Transform($action->query);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
180 } elsif ($param and not ref $param) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
181 return $params->{$param} || $action->query->param($param);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
182 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
183 die InvalidOpException->new("Unsupported parameter mapping", $param);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
184 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
185 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
186 return undef;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
187 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
188 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
189
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
190 1;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
191
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
192 __END__
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
193
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
194 =pod
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
195
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
196 =head1 NAME
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
197
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
198 C<IMPL::Web::Application::RestResource> - ресурс Rest вебсервиса.
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
199
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
200 =head1 SYNOPSIS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
201
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
202 =begin text
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
203
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
204 [REQUEST]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
205 GET /artists
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
206
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
207 [RESPONSE]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
208 <artists>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
209 <artist id="1">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
210 <name>The Beatles <name/>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
211 </atrist>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
212 <artist id="2">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
213 <name>Bonobo</name>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
214 </artist>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
215 </artists>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
216
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
217 [REQUEST]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
218 GET /artists/1/cds?title='Live at BBC'
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
219
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
220 [RESPONSE]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
221 <cds>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
222 <cd id="14">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
223 <title>Live at BBC 1</title>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
224 </cd>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
225 <cd id="15">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
226 <title>Live at BBC 2</title>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
227 </cd>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
228 </cds>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
229
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
230 [REQUEST]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
231 GET /cds/15
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
232
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
233 [RESPONSE]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
234 <cd id="15">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
235 <title>Live at BBC 2</title>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
236 </cd>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
237
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
238 =end text
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
239
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
240 =begin code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
241
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
242 use IMPL::require {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
243 TRes => 'IMPL::Web:Application::RestResource',
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
244 DataContext => 'My::App::DataContext'
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
245 };
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
246
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
247 my $cds = TRes->new(
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
248 DataContext->Default,
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
249 {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
250 methods => {
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
251 history => {
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
252 get => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
253 method => 'GetHistory',
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
254 parameters => [qw(from to)]
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
255 },
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
256 },
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
257 rating => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
258 get => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
259 method => 'GetRating'
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
260 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
261 post => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
262 method => 'Vote',
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
263 parameters => [qw(id rating comment)]
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
264 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
265 }
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
266 }
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
267 index => {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
268 method => 'search',
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
269 paremeters => [qw(filter page limit)]
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
270 },
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
271 fetch => 'GetItemById'
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
272 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
273 );
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
274
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
275 =end code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
276
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
277 =head1 DESCRIPTION
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
278
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
279 Каждый ресурс представляет собой коллекцию и реализует методы C<HTTP> C<GET,POST,PUT,DELETE>.
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
280
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
281 Вызов каждого из этих методов позволяет выполнить одну из операций над ресурсом, однако
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
282 операций может быть больше, для этого создаются дочерние ресурсы (каждый из которых также
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
283 может иметь четыре метода C<GET,POST,PUT,DELETE>), однако обращения к методам у дочерних
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
284 ресурсов отображаются в вызовы методов у родительского ресурса.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
285
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
286 Такой подход позволяет расширить функциональность не изменяя стандарт C<HTTP>, а также обойти
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
287 ограничения браузеров на методы C<PUT,DELETE>.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
288
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
289 Данный тип ресутсов расчитан на использование с конфигурацией, которую можно будет
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
290 сохранить или прочитать, например, из файла. Для этого у ресурса есть ряд настроек,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
291 которые позволяют в простой форме задать отображения между C<HTTP> методами и методами
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
292 объекта представленного данным ресурсом.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
293
200
sergey
parents: 199
diff changeset
294
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
295 =head2 HTTP METHODS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
296
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
297 =head3 C<GET>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
298
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
299 Возвращает данные из текущего ресурса. Обращение к данному методу не должно вносить
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
300 изменений в ресурсы.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
301
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
302 =head3 C<PUT>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
303
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
304 Обновляет ресурс. Повторное обращение к данному методу должно приводить к одному и
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
305 томуже результату.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
306
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
307 =head3 C<DELETE>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
308
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
309 Удаляет ресурс.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
310
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
311 =head3 C<POST>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
312
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
313 Данный метод может вести себя как угодно, однако обычно он используется для добавления
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
314 нового дочернего ресурса в коллекцию,также может использоваться для вызова метода, в случае
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
315 если происходит публикация методов в качестве дочерних ресурсов.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
316
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
317 =head1 BROWSER COMPATIBILITY
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
318
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
319 Однако существует проблема с браузерами, поскольку тег C<< <form> >> реализет только методы
200
sergey
parents: 199
diff changeset
320 C<GET,POST>. Для решения данной проблемы используется режим совместимости C<enableForms>. В
sergey
parents: 199
diff changeset
321 случае когда данный режим активен, автоматически публикуются дочерние ресурсы C<create,edit,delete>.
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
322
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
323 Данные ресуры пбликуются как методы, что означает то, что обращения к ним будут превращены в
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
324 выполнения соответсвующих методов на родительском объекте.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
325
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
326 =head2 C<create>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
327
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
328 По сути данные ресурс не является необходимостью, однако создается для целостности модели.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
329
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
330 =head3 C<GET>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
331
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
332 Передает управление методу C<get>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
333
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
334 =head3 C<POST>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
335
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
336 Передает управление методу C<post>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
337
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
338 =head2 C<edit>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
339
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
340 =head3 C<GET>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
341
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
342 Передает управление методу C<get>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
343
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
344 =head3 C<POST>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
345
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
346 Передает управление методу C<put>, как если бы он был выполнен непосредственно у
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
347 родительского ресурса.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
348
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
349 =head2 C<delete>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
350
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
351 =head3 C<GET>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
352
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
353 Передает управление методу C<get>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
354
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
355 =head3 C<POST>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
356
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
357 Передает управление методу C<delete>, , как если бы он был выполнен непосредственно у
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
358 родительского ресурса.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
359
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
360 =head1 METHOD DEFINITIONS
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
361
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
362 Все методы ресурсов данного типа задаются описаниями, хранящимися в соответствующих
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
363 свойствах. Когда наступает необходимость вызова соответствующего метода, его описание
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
364 бедется из свойства и передается методу C<InvokeMember>, который и производит вызов.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
365
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
366 =head2 C<HASH>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
367
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
368 Содержит в себе описание метода, который нужно вызвать, а также его параметры.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
369
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
370 =over
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
371
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
372 =item C<method>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
373
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
374 Имя метода который будет вызван.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
375
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
376 =item C<paremeters>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
377
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
378 Описание параметров метода, может быть либо массивом, либо хешем, либо простым
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
379 значением.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
380
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
381 =over
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
382
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
383 =item C<ARRAY>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
384
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
385 Метод получает список параметров, каждый элемент данного массива будет превращен
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
386 в параметр при помощи метода C<MakeParameter>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
387
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
388 =item C<HASH>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
389
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
390 Метод получает список параметров, который состоит пар ключ-значение, каждое значение
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
391 данного хеша будет превращено в зачение параметра метода при помощи метода C<MakeParameter>.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
392 Ключи хеша изменениям не подвергаются.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
393
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
394 =item Простое значение
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
395
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
396 Метод получает одно значение, которое будет получено из текущего при помощи C<MakeParameter>.
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
397
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
398 =back
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
399
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
400 =back
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
401
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
402 =head2 C<CODE>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
403
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
404 Если в описании метода находится ссылка на функцию, то эта функция будет вызвана с параметрами.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
405 Данный вариант полезен когда ресурсы создаются програмно обычного механизма описаний не достаточно
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
406 для реализации требуемого функционала.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
407
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
408 =over
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
409
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
410 =item C<$resource>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
411
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
412 Текущий ресурс у которого производится вызов метода.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
413
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
414 =item C<$action>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
415
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
416 Текущий запрос C<IMPL::Web::Application::Action>.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
417
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
418 =back
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
419
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
420 =head2 Простое значение
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
421
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
422 Интерпретируется как имя метода у объекта данных текущего ресурса.
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
423
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
424 =head1 MEMBERS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
425
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
426 =head2 C<[get]id>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
427
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
428 Идентификатор текущего ресурса.
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
429
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
430 =head2 C<[get]target>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
431
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
432 Объект данных (может быть и класс, поскольку у него будут только вызываться
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
433 методы), обеспечивающий функционал ресурса.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
434
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
435 =head2 C<[get]parent>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
436
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
437 Родительский ресурс, в котором находится текущий ресурс. Может быть C<undef>,
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
438 если текущий ресурс является корнем.
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
439
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
440 =head2 C<[get]methods>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
441
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
442 Содержит описания методов, которые будут публиковаться как дочерние ресурсы.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
443
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
444 =head2 C<[get]childRegex>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
445
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
446 Содержит регулярное выражение для идентификаторов дочерних объектов. Если оно
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
447 не задано, то данный ресурс не является коллекцией.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
448
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
449 =head2 C<[get]fetch>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
450
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
451 Содержит описание метода для получения дочернего объекта. Если данный метод
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
452 отсутствует, то дочерние ресурсы не получится адресовать относительно данного.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
453 По умолчанию получает идентификатор дочернего ресурса первым параметром.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
454
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
455 =head2 C<[get]index>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
456
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
457 Описание метода для получения списка дочерних объектов. По умолчанию не
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
458 получает параметров.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
459
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
460 =head2 C<[get]post>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
461
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
462 Описание метода для добавление дочернего ресурса. По умолчанию получает
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
463 объект C<CGI> описывабщий текущий запрос первым параметром.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
464
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
465 =head2 C<[get]put>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
466
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
467 Описание метода для обновления дочернего ресурса. По умолчанию получает
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
468 объект C<CGI> текущего запроса.
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
469
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
470 =head2 C<[get]delete>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
471
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
472 Описание метода для удаления дочернего ресурса. По умолчанию не получает
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
473 параметров.
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
474
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
475 =head2 C<GetImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
476
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
477 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
478
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
479 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
480
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
481 Текущий запрос C<IMPL::Web::Application::Action>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
482
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
483 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
484
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
485 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
486 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
487
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
488 =head2 C<PutImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
489
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
490 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
491
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
492 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
493
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
494 Текущий запрос C<IMPL::Web::Application::Action>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
495
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
496 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
497
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
498 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
499 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
500
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
501 =head2 C<PostImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
502
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
503 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
504
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
505 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
506
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
507 Текущий запрос C<IMPL::Web::Application::Action>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
508
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
509 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
510
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
511 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
512 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
513
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
514 =head2 C<DeleteImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
515
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
516 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
517
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
518 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
519
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
520 Текущий запрос C<IMPL::Web::Application::Action>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
521
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
522 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
523
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
524 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
525 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
526
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
527 =head2 C<InvokeMember($memberInfo,$action,$params)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
528
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
529 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
530
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
531 =item C<$memberInfo>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
532
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
533 Описание члена внутреннего объекта C<target>, который нужно вызвать.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
534
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
535 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
536
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
537 Текущий запрос C<IMPL::Web::Application::Action>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
538
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
539 =item C<$params>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
540
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
541 Ссылка на хеш с предопределенными параметрами.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
542
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
543 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
544
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
545 Вызывает метод внутреннего объекта C<target>, предварительно подготовив
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
546 параметры на основе описания C<$memberInfo> и при помощи С<MakeParameter()>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
547
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
548 =head2 C<MakeParameter($paramDef,$action)>
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
549
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
550 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
551
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
552 =item C<$paramDef>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
553
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
554 Описание параметра, может быть C<IMPL::Transform> или простая строка.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
555
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
556 Если описание параметра - простая строка, то ее имя либо
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
557
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
558 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
559
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
560 =item C<id>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
561
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
562 Идентификатор ресурса
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
563
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
564 =item C<query>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
565
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
566 Объект C<CGI> текущего запроса
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
567
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
568 =item C<action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
569
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
570 Текущий запрос C<IMPL::Web::Application::Action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
571
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
572 =item C<любое другое значение>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
573
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
574 Интерпретируется как параметр текущего запроса.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
575
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
576 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
577
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
578 Если описание параметра - объект C<IMPL::Transform>, то будет выполнено это преобразование над C<CGI>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
579 объектом текущего запроса C<< $paramDef->Transform($action->query) >>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
580
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
581 =item C<$action>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
582
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
583 Текущий запрос
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
584
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
585 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
586
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
587 =cut