__PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC);
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90116';
+our $VERSION = '5.90117';
$VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
sub import {
=item \@captures_and_args?
-Optional array reference of Captures (i.e. C<<CaptureArgs or $c->req->captures>)
+Optional array reference of Captures (i.e. C<CaptureArgs> or C<< $c->req->captures >>)
and arguments to the request. Usually used with L<Catalyst::DispatchType::Chained>
to interpolate all the parameters in the URI.
my $config = MyApp->config_for('MyApp::Model::Foo');
-In this case $config is the hashref C< {a=>1, b=>2} >.
+In this case $config is the hashref C<< {a=>1, b=>2} >>.
This is also handy for looking up configuration for a plugin, to make sure you follow
existing L<Catalyst> standards for where a plugin should put its configuration.
L<CGI::Struct> or via L<CGI::Struct::XS> IF you've installed it.
The 'application/json' data handler is used to parse incoming JSON into a Perl
-data structure. It used either L<JSON::MaybeXS> or L<JSON>, depending on which
-is installed. This allows you to fail back to L<JSON:PP>, which is a Pure Perl
-JSON decoder, and has the smallest dependency impact.
+data structure. It uses L<JSON::MaybeXS>. This allows you to fail back to
+L<JSON::PP>, which is a Pure Perl JSON decoder, and has the smallest dependency
+impact.
Because we don't wish to add more dependencies to L<Catalyst>, if you wish to
-use this new feature we recommend installing L<JSON> or L<JSON::MaybeXS> in
-order to get the best performance. You should add either to your dependency
-list (Makefile.PL, dist.ini, cpanfile, etc.)
+use this new feature we recommend installing L<Cpanel::JSON::XS> in order to get
+the best performance. You should add either to your dependency list
+(Makefile.PL, dist.ini, cpanfile, etc.)
=cut
},
'application/json' => sub {
my ($fh, $req) = @_;
- my $parser = Class::Load::load_first_existing_class('JSON::MaybeXS', 'JSON');
+ require JSON::MaybeXS;
my $slurped;
return eval {
local $/;
$slurped = $fh->getline;
- $parser->can("decode_json")->($slurped); # decode_json does utf8 decoding for us
+ JSON::MaybeXS::decode_json($slurped); # decode_json does utf8 decoding for us
} || Catalyst::Exception->throw(sprintf "Error Parsing POST '%s', Error: %s", (defined($slurped) ? $slurped : 'undef') ,$@);
},
};
L<< stats_class|/"$c->stats_class" >>.
Even if L<< -Stats|/"-Stats" >> is not enabled, the stats object is still
-available. By enabling it with C< $c->stats->enabled(1) >, it can be used to
+available. By enabling it with C<< $c->stats->enabled(1) >>, it can be used to
profile explicitly, although MyApp.pm still won't profile nor output anything
by itself.
package MyApp::Web;
use Catalyst;
- use JSON::Maybe;
+ use JSON::MaybeXS;
__PACKAGE__->config(
data_handlers => {
__PACKAGE__->setup;
By default L<Catalyst> comes with a generic JSON data handler similar to the
-example given above, which uses L<JSON::Maybe> to provide either L<JSON::PP>
+example given above, which uses L<JSON::MaybeXS> to provide either L<JSON::PP>
(a pure Perl, dependency free JSON parser) or L<Cpanel::JSON::XS> if you have
it installed (if you want the faster XS parser, add it to you project Makefile.PL
or dist.ini, cpanfile, etc.)