annotate Lib/IMPL/Web/Application/RestResource.pm @ 202:5146e17a7b76

IMPL::Web::Application::RestResource fixes, documentation
author sergey
date Wed, 25 Apr 2012 02:49:23 +0400
parents 0c018a247c8a
children 292226770180
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 {
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
35 my ($this) = @_;
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
200
sergey
parents: 199
diff changeset
42 if ($this->enableForms) {
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
43 $this->methods->{create} = {
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
44 get => $this->get,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
45 post => $this->post,
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
46 final => 1 # this resource doesn't have any children
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
47 } if $this->post;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
48
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
49 $this->methods->{edit} = {
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
50 get => $this->get,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
51 post => $this->put,
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
52 final => 1 # this resource doesn't have any children
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
53 } if $this->put;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
54
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
55 $this->methods->{delete} {
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
56 get => $this->get,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
57 post => $this->delete,
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
58 final => 1 # this resource doesn't have any children
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
59 } if $this->delete;
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
60 }
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
61 }
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
62
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
63 # создает дочерний ресурс из описания, однако все методы созданного
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
64 # ресурса переадресуются к его родителю, это нужно, чтобы публиковать
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 sub _CreateSubResource {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
67 my ($this,$resource,$id) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
68
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
69 my %methods = map {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
70 my $method = $resource->{$_};
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
71 $_ => sub {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
72 my ($this,$action) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
73 return $this->parent->InvokeMember($method,$action);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
74 };
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
75 } grep $resource->{$_}, qw(get post put delete);
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 return CustomResource->new(
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
78 %methods,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
79 final => $resource->{final},
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
80 parent => $this,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
81 id => $id,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
82 contract => $this->contract
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
83 );
200
sergey
parents: 199
diff changeset
84 }
sergey
parents: 199
diff changeset
85
sergey
parents: 199
diff changeset
86 sub FetchChildResource {
sergey
parents: 199
diff changeset
87 my ($this,$id,$action) = @_;
sergey
parents: 199
diff changeset
88
sergey
parents: 199
diff changeset
89 my $rx = $this->childRegex;
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
90
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
91 my $res;
200
sergey
parents: 199
diff changeset
92
sergey
parents: 199
diff changeset
93 if (length $id == 0) {
sergey
parents: 199
diff changeset
94
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
95 my $method = $this->index;
200
sergey
parents: 199
diff changeset
96 die ForbiddenException->new() unless $method;
sergey
parents: 199
diff changeset
97
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
98 $res = $this->InvokeMember($method,$action);
200
sergey
parents: 199
diff changeset
99
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
100 } elsif ($this->methods and my $resource = $this->methods->{$id}) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
101
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
102 return $this->_CreateSubResource($resource,$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 } elsif ($rx and $id =~ m/^$rx$/ and my $method = $this->fetch) {
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 $method = {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
107 method => $method,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
108 parameters => 'id'
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
109 } unless ref $method;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
110
201
0c018a247c8a Reworked REST resource classes to be more transparent and intuitive
sergey
parents: 200
diff changeset
111 $res = $this->InvokeMember($method,$action, { id => $id } );
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
112
200
sergey
parents: 199
diff changeset
113 }
sergey
parents: 199
diff changeset
114
sergey
parents: 199
diff changeset
115 die NotFoundException->new() unless defined $res;
sergey
parents: 199
diff changeset
116
sergey
parents: 199
diff changeset
117 return $this->contract->Transform($res, {parent => $this, id => $id} );
sergey
parents: 199
diff changeset
118 }
sergey
parents: 199
diff changeset
119
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
120 sub InvokeMember {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
121 my ($this,$method,$action,$predefined) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
122
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
123 die ArgumentException->new("method","No method information provided") unless $method;
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 #normalize method info
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
126 if (not ref $method) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
127 $method = {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
128 method => $method
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
129 };
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
130 }
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 if (ref $method eq 'HASH') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
133 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
134
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
135 $member = $member->Invoke($this) if eval { $member->isa(TResolve) };
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 my @args;
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 if (my $params = $method->{parameters}) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
140 if (ref $params eq 'HASH') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
141 @args = map {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
142 $_,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
143 $this->MakeParameter($params->{$_},$action,$predefined)
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
144 } keys %$params;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
145 } elsif (ref $params eq 'ARRAY') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
146 @args = map $this->MakeParameter($_,$action,$predefined), @$params;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
147 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
148 @args = ($this->MakeParameter($params,$action,$predefined));
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
149 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
150 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
151 return $this->target->$member(@args);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
152 } elsif (ref $method eq TResolve) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
153 return $method->Invoke($this);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
154 } elsif (ref $method eq 'CODE') {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
155 return $method->($this,$action);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
156 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
157 die InvalidOpException->new("Unsupported type of the method information", ref $method);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
158 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
159 }
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 sub MakeParameter {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
162 my ($this,$param,$action,$predefined) = @_;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
163
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
164 my $params = hashApply(
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 id => $this->id,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
167 action => $action,
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
168 query => $action->query
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
169 },
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
170 $predefined || {}
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
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 if ($param) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
176 if (is $param, TTransform ) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
177 return $param->Transform($action->query);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
178 } elsif ($param and not ref $param) {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
179 return $params->{$param} || $action->query->param($param);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
180 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
181 die InvalidOpException->new("Unsupported parameter mapping", $param);
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
182 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
183 } else {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
184 return undef;
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
185 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
186 }
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
187
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
188 1;
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
189
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
190 __END__
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
191
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
192 =pod
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
193
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
194 =head1 NAME
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
195
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
196 C<IMPL::Web::Application::RestResource> - ресурс Rest вебсервиса.
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
197
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
198 =head1 SYNOPSIS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
199
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
200 =begin text
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 [REQUEST]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
203 GET /artists
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
204
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
205 [RESPONSE]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
206 <artists>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
207 <artist id="1">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
208 <name>The Beatles <name/>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
209 </atrist>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
210 <artist id="2">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
211 <name>Bonobo</name>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
212 </artist>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
213 </artists>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
214
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
215 [REQUEST]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
216 GET /artists/1/cds?title='Live at BBC'
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
217
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
218 [RESPONSE]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
219 <cds>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
220 <cd id="14">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
221 <title>Live at BBC 1</title>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
222 </cd>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
223 <cd id="15">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
224 <title>Live at BBC 2</title>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
225 </cd>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
226 </cds>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
227
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
228 [REQUEST]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
229 GET /cds/15
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
230
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
231 [RESPONSE]
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
232 <cd id="15">
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
233 <title>Live at BBC 2</title>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
234 </cd>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
235
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
236 =end text
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 =begin code
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 use IMPL::require {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
241 TRes => 'IMPL::Web:Application::RestResource',
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
242 DataContext => 'My::App::DataContext'
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
243 };
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
244
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
245 my $cds = TRes->new(
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
246 DataContext->Default,
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
247 {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
248 methods => {
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
249 history => {
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
250 get => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
251 method => 'GetHistory',
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
252 parameters => [qw(from to)]
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
253 },
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
254 },
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
255 rating => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
256 get => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
257 method => 'GetRating'
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
258 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
259 post => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
260 method => 'Vote',
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
261 parameters => [qw(id rating comment)]
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
262 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
263 }
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
264 }
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
265 index => {
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
266 method => 'search',
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
267 paremeters => [qw(filter page limit)]
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
268 },
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
269 fetch => 'GetItemById'
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
270 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
271 );
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 =end code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
274
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
275 =head1 DESCRIPTION
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
276
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
277 Каждый ресурс представляет собой коллекцию и реализует методы C<HTTP> C<GET,POST,PUT,DELETE>.
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
278
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
279 Вызов каждого из этих методов позволяет выполнить одну из операций над ресурсом, однако
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
280 операций может быть больше, для этого создаются дочерние ресурсы (каждый из которых также
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
281 может иметь четыре метода C<GET,POST,PUT,DELETE>), однако обращения к методам у дочерних
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
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
284 Такой подход позволяет расширить функциональность не изменяя стандарт C<HTTP>, а также обойти
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
285 ограничения браузеров на методы C<PUT,DELETE>.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
286
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
287 Данный тип ресутсов расчитан на использование с конфигурацией, которую можно будет
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 которые позволяют в простой форме задать отображения между C<HTTP> методами и методами
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
200
sergey
parents: 199
diff changeset
292
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
293 =head2 HTTP METHODS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
294
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
295 =head3 C<GET>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
296
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
297 Возвращает данные из текущего ресурса. Обращение к данному методу не должно вносить
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
298 изменений в ресурсы.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
299
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
300 =head3 C<PUT>
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 Обновляет ресурс. Повторное обращение к данному методу должно приводить к одному и
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
303 томуже результату.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
304
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
305 =head3 C<DELETE>
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 Удаляет ресурс.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
308
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
309 =head3 C<POST>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
310
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
311 Данный метод может вести себя как угодно, однако обычно он используется для добавления
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
312 нового дочернего ресурса в коллекцию,также может использоваться для вызова метода, в случае
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
313 если происходит публикация методов в качестве дочерних ресурсов.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
314
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
315 =head1 BROWSER COMPATIBILITY
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
316
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
317 Однако существует проблема с браузерами, поскольку тег C<< <form> >> реализет только методы
200
sergey
parents: 199
diff changeset
318 C<GET,POST>. Для решения данной проблемы используется режим совместимости C<enableForms>. В
sergey
parents: 199
diff changeset
319 случае когда данный режим активен, автоматически публикуются дочерние ресурсы C<create,edit,delete>.
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
320
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
321 Данные ресуры пбликуются как методы, что означает то, что обращения к ним будут превращены в
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
322 выполнения соответсвующих методов на родительском объекте.
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 =head2 C<create>
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 По сути данные ресурс не является необходимостью, однако создается для целостности модели.
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 =head3 C<GET>
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 Передает управление методу C<get>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
331
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
332 =head3 C<POST>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
333
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
334 Передает управление методу 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 =head2 C<edit>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
337
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
338 =head3 C<GET>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
339
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
340 Передает управление методу 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 =head3 C<POST>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
343
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
344 Передает управление методу C<put>, как если бы он был выполнен непосредственно у
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
345 родительского ресурса.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
346
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
347 =head2 C<delete>
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 =head3 C<GET>
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 Передает управление методу 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 =head3 C<POST>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
354
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
355 Передает управление методу C<delete>, , как если бы он был выполнен непосредственно у
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
356 родительского ресурса.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
357
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
358 =head1 METHOD DEFINITIONS
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
359
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
360 Все методы ресурсов данного типа задаются описаниями, хранящимися в соответствующих
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
361 свойствах. Когда наступает необходимость вызова соответствующего метода, его описание
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
362 бедется из свойства и передается методу C<InvokeMember>, который и производит вызов.
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 =head2 C<HASH>
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 Содержит в себе описание метода, который нужно вызвать, а также его параметры.
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 =over
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
369
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
370 =item C<method>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
371
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
372 Имя метода который будет вызван.
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 =item C<paremeters>
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 Описание параметров метода, может быть либо массивом, либо хешем, либо простым
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 =over
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 =item C<ARRAY>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
382
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
383 Метод получает список параметров, каждый элемент данного массива будет превращен
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
384 в параметр при помощи метода C<MakeParameter>
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 =item C<HASH>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
387
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
388 Метод получает список параметров, который состоит пар ключ-значение, каждое значение
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
389 данного хеша будет превращено в зачение параметра метода при помощи метода C<MakeParameter>.
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
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
392 =item Простое значение
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 Метод получает одно значение, которое будет получено из текущего при помощи C<MakeParameter>.
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
395
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
396 =back
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
397
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 =head2 C<CODE>
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 Если в описании метода находится ссылка на функцию, то эта функция будет вызвана с параметрами.
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 =over
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
407
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
408 =item C<$resource>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
409
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
410 Текущий ресурс у которого производится вызов метода.
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 =item C<$action>
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
413
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
414 Текущий запрос C<IMPL::Web::Application::Action>.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
415
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
416 =back
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 =head2 Простое значение
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 Интерпретируется как имя метода у объекта данных текущего ресурса.
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
421
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
422 =head1 MEMBERS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
423
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
424 =head2 C<[get]id>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
425
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
426 Идентификатор текущего ресурса.
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
427
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
428 =head2 C<[get]target>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
429
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
430 Объект данных (может быть и класс, поскольку у него будут только вызываться
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
431 методы), обеспечивающий функционал ресурса.
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
432
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
433 =head2 C<[get]parent>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
434
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents: 198
diff changeset
435 Родительский ресурс, в котором находится текущий ресурс. Может быть C<undef>,
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
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
438 =head2 C<[get]methods>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
439
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
440 Содержит описания методов, которые будут публиковаться как дочерние ресурсы.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
441
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
442 =head2 C<[get]childRegex>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
443
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
444 Содержит регулярное выражение для идентификаторов дочерних объектов. Если оно
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
445 не задано, то данный ресурс не является коллекцией.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
446
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
447 =head2 C<[get]fetch>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
448
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
449 Содержит описание метода для получения дочернего объекта. Если данный метод
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
450 отсутствует, то дочерние ресурсы не получится адресовать относительно данного.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
451 По умолчанию получает идентификатор дочернего ресурса первым параметром.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
452
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
453 =head2 C<[get]index>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
454
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
455 Описание метода для получения списка дочерних объектов. По умолчанию не
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
456 получает параметров.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
457
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
458 =head2 C<[get]post>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
459
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
460 Описание метода для добавление дочернего ресурса. По умолчанию получает
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
461 объект C<CGI> описывабщий текущий запрос первым параметром.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
462
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
463 =head2 C<[get]put>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
464
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
465 Описание метода для обновления дочернего ресурса. По умолчанию получает
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
466 объект C<CGI> текущего запроса.
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
467
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
468 =head2 C<[get]delete>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
469
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
470 Описание метода для удаления дочернего ресурса. По умолчанию не получает
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
471 параметров.
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
472
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
473 =head2 C<GetImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
474
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
475 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
476
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
477 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
478
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
479 Текущий запрос C<IMPL::Web::Application::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 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
482
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
483 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
484 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
485
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
486 =head2 C<PutImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
487
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
488 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
489
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
490 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
491
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
492 Текущий запрос C<IMPL::Web::Application::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 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
495
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
496 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
497 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
498
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
499 =head2 C<PostImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
500
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
501 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
502
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
503 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
504
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
505 Текущий запрос C<IMPL::Web::Application::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 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
508
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
509 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
510 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
511
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
512 =head2 C<DeleteImpl($action)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
513
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
514 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
515
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
516 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
517
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
518 Текущий запрос C<IMPL::Web::Application::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 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
521
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
522 Переадресует запрос нужному методу внутреннего объекта C<target> при
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
523 помощи C<InvokeMember>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
524
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
525 =head2 C<InvokeMember($memberInfo,$action,$params)>
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents: 196
diff changeset
526
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
527 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
528
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
529 =item C<$memberInfo>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
530
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
531 Описание члена внутреннего объекта C<target>, который нужно вызвать.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
532
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
533 =item C<$action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
534
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
535 Текущий запрос C<IMPL::Web::Application::Action>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
536
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
537 =item C<$params>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
538
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
539 Ссылка на хеш с предопределенными параметрами.
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
540
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
541 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
542
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
543 Вызывает метод внутреннего объекта C<target>, предварительно подготовив
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
544 параметры на основе описания C<$memberInfo> и при помощи С<MakeParameter()>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
545
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
546 =head2 C<MakeParameter($paramDef,$action)>
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
547
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
548 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
549
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
550 =item C<$paramDef>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
551
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
552 Описание параметра, может быть C<IMPL::Transform> или простая строка.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
553
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
554 Если описание параметра - простая строка, то ее имя либо
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
555
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
556 =over
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
557
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
558 =item C<id>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
559
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
560 Идентификатор ресурса
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
561
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
562 =item C<query>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
563
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
564 Объект C<CGI> текущего запроса
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
565
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
566 =item C<action>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
567
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
568 Текущий запрос C<IMPL::Web::Application::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 =item C<любое другое значение>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
571
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
572 Интерпретируется как параметр текущего запроса.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
573
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
574 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
575
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
576 Если описание параметра - объект C<IMPL::Transform>, то будет выполнено это преобразование над C<CGI>
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
577 объектом текущего запроса C<< $paramDef->Transform($action->query) >>.
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
578
202
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
579 =item C<$action>
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
580
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
581 Текущий запрос
5146e17a7b76 IMPL::Web::Application::RestResource fixes, documentation
sergey
parents: 201
diff changeset
582
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
583 =back
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
584
196
a705e848dcc7 added IMPL::Config::Reference
cin
parents:
diff changeset
585 =cut