Catalyst-TraitFor-Request-QueryFromJSONY

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

# This file documents the revision history for Perl extension Catalyst-TraitFor-Request-QueryFromJSONY

0.002 - 2015-10-01
  - Make it easier when you have more then 'q' as JSONY parameters.
  - removed 'has_query_data' method since its no longer useful (could be a
    breaking change for you but easy to work around).
  - Add some callbacks to handle common exception conditions, like when
    JSONY can't parse the values, or the value doesn't exist.
  - Change to Moo from Moose (won't have any impact on code now, but if
    Catalyst ever moves bits to Moo, this we be better preparation).

0.001 - 2015-08-05
  - First Release 

README.mkdn  view on Meta::CPAN

This role defines the following methods.

## query\_data (?@query\_params, ?\\%options)

For each item in @query\_params that exists in $request->query\_parameters deserialize
using [JSONY](https://metacpan.org/pod/JSONY)  and return the data references (could be a hashref, or arrayref 
depending on the query construction.

If no @query\_params are submitted, assume 'q' as the default.

The %options hash allows you to set callback to handle exceptional conditions. All callbacks
get invoked with two parameters, the current $request object, and the name of the
query parameter that caused the condition.  For example the follow substitutes the string
'\[\]' when a $key is missing from %{$c->req->query\_parameters}:

    $c->req->query_data(qw/a b c/, +{ 
      param_missing => sub {
        my ($req, $key) = @_;
        return '[]';
      }
    });

lib/Catalyst/TraitFor/Request/QueryFromJSONY.pm  view on Meta::CPAN

This role defines the following methods.

=head2 query_data (?@query_params, ?\%options)

For each item in @query_params that exists in $request->query_parameters deserialize
using L<JSONY>  and return the data references (could be a hashref, or arrayref 
depending on the query construction.

If no @query_params are submitted, assume 'q' as the default.

The %options hash allows you to set callback to handle exceptional conditions. All callbacks
get invoked with two parameters, the current $request object, and the name of the
query parameter that caused the condition.  For example the follow substitutes the string
'[]' when a $key is missing from %{$c->req->query_parameters}:

    $c->req->query_data(qw/a b c/, +{ 
      param_missing => sub {
        my ($req, $key) = @_;
        return '[]';
      }
    });



( run in 1.160 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )