Codebase list libdancer2-perl / b802279
Merge branch 'feature/unicode-utf8' Jason A. Crome 2 years ago
7 changed file(s) with 21 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
55 [ ENHANCEMENTS ]
66 * GH #769, PR #829, #1662: Rename show_errors as show_stacktrace
77 (Nuno Ramos Carvalho, Sawyer X)
8 * GH #1594: Use Unicode::UTF8 if available (Sawyer X)
89
910 [ DOCUMENTATION ]
1011 * GH #1657: Fix the Dancer2::DeprecationPolicy abstract (Jason A. Crome)
6868 recommends 'Type::Tiny::XS';
6969 recommends 'URL::Encode::XS';
7070 recommends 'YAML::XS';
71 recommends 'Unicode::UTF8';
7172
7273 suggests 'Fcntl';
7374 suggests 'MIME::Types';
77 use Safe::Isa;
88 use Sub::Quote;
99 use File::Spec;
10 use Module::Runtime 'use_module';
10 use Module::Runtime qw< require_module use_module >;
1111 use List::Util ();
1212 use Ref::Util qw< is_ref is_globref is_scalarref >;
1313
1010 use URI::Escape;
1111 use Safe::Isa;
1212 use Hash::MultiValue;
13 use Module::Runtime 'require_module';
1413 use Ref::Util qw< is_ref is_arrayref is_hashref >;
1514
1615 use Dancer2::Core::Types;
3635 1;
3736 _EVAL
3837
38 eval {
39 require Unicode::UTF8;
40 no warnings qw<redefine once>;
41 *__decode = sub { Unicode::UTF8::decode_utf8($_[0]) };
42 1;
43 } or do {
44 no warnings qw<redefine once>;
45 *__decode = sub { decode( 'UTF-8', $_[0] ) };
46 };
47
3948 # check presence of XS module to speedup request
40 our $XS_URL_DECODE = eval { require_module('URL::Encode::XS'); 1; };
41 our $XS_PARSE_QUERY_STRING = eval { require_module('CGI::Deurl::XS'); 1; };
42 our $XS_HTTP_COOKIES = eval { require_module('HTTP::XSCookies'); 1; };
49 our $XS_URL_DECODE = eval { require URL::Encode::XS; 1; };
50 our $XS_PARSE_QUERY_STRING = eval { require CGI::Deurl::XS; 1; };
51 our $XS_HTTP_COOKIES = eval { require HTTP::XSCookies; 1; };
4352
4453 our $_id = 0;
4554
391400 return if not defined $h;
392401
393402 if ( !is_ref($h) && !utf8::is_utf8($h) ) {
394 return decode( 'UTF-8', $h );
403 return __decode($h);
395404 }
396405 elsif ( ref($h) eq 'Hash::MultiValue' ) {
397406 return Hash::MultiValue->from_mixed(_decode($h->as_hashref_mixed));
500500 # or croak('Could not find Dancer2 app');
501501
502502 return $class;
503 };
503 }
504504
505505 # This has to be called for now at the end of every plugin package, in order to
506506 # map the keywords of the associated app to the plugin, so that these keywords
1111 recommends "Math::Random::ISAAC::XS" => "0";
1212 recommends "MooX::TypeTiny" => "0";
1313 recommends "Type::Tiny::XS" => "0";
14 recommends "Unicode::UTF8" => "0";
1415
1516 feature 'accelerate', 'Accelerate Dancer2 app performance with XS modules' => sub {
1617 requires "URL::Encode::XS" => "0";
2425 requires "Math::Random::ISAAC::XS" => "0";
2526 requires "MooX::TypeTiny" => "0";
2627 requires "Type::Tiny::XS" => "0";
28 requires "Unicode::UTF8" => "0";
2729 };
2830
2931 on "test" => sub {
131131 $bench->report;
132132 } else {
133133 print << "_END_HELP";
134 $0 -- <-s | --speed 1|2|3|4|5> <profile | bench | compare>
134 $0 -- <-s | --speed 1|2|3|4|5> <--profile | --bench | --compare>
135135 ("--" is required before parameters because D1 parses ARGV)
136136
137137 Commands: