X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=8fc94d6c42af5a0cd1fff1d0338ccbcc3d8fdfff;hp=19b2dfadc4fe73d7855c26cb7b15f10807737459;hb=974733c0febbddd53145ec82031b4ad6abcc0985;hpb=b87d834e205e69128e7385f213ab32a7a7bc541f diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 19b2dfa..8fc94d6 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -41,7 +41,7 @@ use Plack::Middleware::IIS6ScriptNameFix; use Plack::Middleware::IIS7KeepAliveFix; use Plack::Middleware::LighttpdScriptNameFix; use Plack::Util; -use JSON::MaybeXS qw(decode_json); +use Class::Load; BEGIN { require 5.008003; } @@ -117,7 +117,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90049_001'; +our $VERSION = '5.90049_002'; sub import { my ( $class, @arguments ) = @_; @@ -1158,7 +1158,7 @@ EOF my @middleware = map { ref $_ eq 'CODE' ? "Inline Coderef" : - (ref($_) .' '. ($_->can('VERSION') ? $_->VERSION : '') + (ref($_) .' '. ($_->can('VERSION') ? $_->VERSION || '' : '') || '') } $class->registered_middlewares; if (@middleware) { @@ -1168,10 +1168,8 @@ EOF $class->log->debug( "Loaded PSGI Middleware:\n" . $t->draw . "\n" ); } - my %dh = $class->registered_data_handlers || (); - my @data_handlers = keys %dh; - - if (@data_handlers) { + my %dh = $class->registered_data_handlers; + if (my @data_handlers = keys %dh) { my $column_width = Catalyst::Utils::term_width() - 6; my $t = Text::SimpleTable->new($column_width); $t->row($_) for @data_handlers; @@ -3162,6 +3160,9 @@ installed it. If you don't mind the XS dependency, you should add the faster L to you dependency list (in your Makefile.PL or dist.ini, or cpanfile, etc.) +L is loaded the first time you ask for it (so if you never ask +for it, its never used). + =cut sub registered_data_handlers { @@ -3186,7 +3187,10 @@ sub setup_data_handlers { sub default_data_handlers { my ($class) = @_; return +{ - 'application/json' => sub { local $/; decode_json $_->getline }, + 'application/json' => sub { + local $/; + Class::Load::load_class("JSON::MaybeXS"); + JSON::MaybeXS::decode_json $_->getline }, }; }