PEF-Front
view release on metacpan or search on metacpan
lib/PEF/Front/Model.pm view on Meta::CPAN
Special key C<extra_params> controls what to do when there're more
parameters as required: B<ignore> - all extra parameters will be
silently deleted; B<pass> - all extra parameters will be passed
without validation; B<disallow> - validation fails when extra parameters
passed.
---
params:
ip: $ip
extra_params: pass
=head2 Output result
Handlers are supposed to return hash like these.
{
result => "OK",
}
or
{
result => "SOMEERRCODE",
answer => 'Some $1 Error $2 Message $3',
answer_args => [$some, $error, $params],
}
C<result> is required in every answer, other keys are optional.
Following keys have some meaning:
=over
=item B<result>
Is symbolic result state.
=over
=item "OK" means everything is good
=item "INTERR" means some internal application error
=item "OAUTHERR" means Oauth protocol error
=item "BADPARAM" means validation error
=back
Application can use its own codes.
=item B<answer>
Message from application. If calling type is C</ajax> and
C<answer_no_nls> is not present or false then this message
will be automatically localized.
When calling type is C</get> or C</submit> then value of this
key can be open file handle or code reference. If value of this
key is code reference then it is "streaming function".
See L<PSGI/"Delayed Response and Streaming Body">.
=item B<answer_args>
Array of arguments to the message.
=item B<answer_headers>
Array of key-value pairs that will be set as output HTTP headers and their
values. Key-value pairs can be list ($header => $value),
array [$header => $value] or hash {$header => $value}.
[
{'X-Hr' => 'x-hr'},
['X-Ar' => 'x-ar'],
'X-Header' => 'x-value'
]
=item B<answer_cookies>
Array of key-value pairs that will be set as output HTTP cookies and their
values. Key-value pairs can be list ($cookie => $value),
array [$cookie => $value] or hash {$cookie => $value}.
[
{ch => 'Chv'},
[ca => 'Cav'],
Cookie => 'cookie_value'
]
=item B<answer_no_nls>
If present and true then C<answer> will be send as is, without localization
attempt.
=item B<answer_status>
Sets HTTP status code. If C<answer_status> is between 300 and 400 then
C<Location> headers specifys new location for redirect.
=item B<answer_content_type>
Sets Content-Type header.
=item B<answer_data>
Replaces answer hash with C<answer_data> field before encoding to JSON.
It can be only B<ARRAY> or B<HASH> reference.
=item B<answer_http_response>
Uses supplied HTTP response object as handler response.
=back
When method is called like C</ajax> then it means JSON format answer.
When you need another output format, use C</get> or C</submit> type calls.
=head2 Response caching
( run in 1.365 second using v1.01-cache-2.11-cpan-39bf76dae61 )