Merge branch 'feature/unicode-utf8'
Jason A. Crome
2 years ago
5 | 5 |
[ ENHANCEMENTS ]
|
6 | 6 |
* GH #769, PR #829, #1662: Rename show_errors as show_stacktrace
|
7 | 7 |
(Nuno Ramos Carvalho, Sawyer X)
|
|
8 |
* GH #1594: Use Unicode::UTF8 if available (Sawyer X)
|
8 | 9 |
|
9 | 10 |
[ DOCUMENTATION ]
|
10 | 11 |
* GH #1657: Fix the Dancer2::DeprecationPolicy abstract (Jason A. Crome)
|
68 | 68 |
recommends 'Type::Tiny::XS';
|
69 | 69 |
recommends 'URL::Encode::XS';
|
70 | 70 |
recommends 'YAML::XS';
|
|
71 |
recommends 'Unicode::UTF8';
|
71 | 72 |
|
72 | 73 |
suggests 'Fcntl';
|
73 | 74 |
suggests 'MIME::Types';
|
7 | 7 |
use Safe::Isa;
|
8 | 8 |
use Sub::Quote;
|
9 | 9 |
use File::Spec;
|
10 | |
use Module::Runtime 'use_module';
|
|
10 |
use Module::Runtime qw< require_module use_module >;
|
11 | 11 |
use List::Util ();
|
12 | 12 |
use Ref::Util qw< is_ref is_globref is_scalarref >;
|
13 | 13 |
|
10 | 10 |
use URI::Escape;
|
11 | 11 |
use Safe::Isa;
|
12 | 12 |
use Hash::MultiValue;
|
13 | |
use Module::Runtime 'require_module';
|
14 | 13 |
use Ref::Util qw< is_ref is_arrayref is_hashref >;
|
15 | 14 |
|
16 | 15 |
use Dancer2::Core::Types;
|
|
36 | 35 |
1;
|
37 | 36 |
_EVAL
|
38 | 37 |
|
|
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 |
|
39 | 48 |
# 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; };
|
43 | 52 |
|
44 | 53 |
our $_id = 0;
|
45 | 54 |
|
|
391 | 400 |
return if not defined $h;
|
392 | 401 |
|
393 | 402 |
if ( !is_ref($h) && !utf8::is_utf8($h) ) {
|
394 | |
return decode( 'UTF-8', $h );
|
|
403 |
return __decode($h);
|
395 | 404 |
}
|
396 | 405 |
elsif ( ref($h) eq 'Hash::MultiValue' ) {
|
397 | 406 |
return Hash::MultiValue->from_mixed(_decode($h->as_hashref_mixed));
|
500 | 500 |
# or croak('Could not find Dancer2 app');
|
501 | 501 |
|
502 | 502 |
return $class;
|
503 | |
};
|
|
503 |
}
|
504 | 504 |
|
505 | 505 |
# This has to be called for now at the end of every plugin package, in order to
|
506 | 506 |
# map the keywords of the associated app to the plugin, so that these keywords
|
11 | 11 |
recommends "Math::Random::ISAAC::XS" => "0";
|
12 | 12 |
recommends "MooX::TypeTiny" => "0";
|
13 | 13 |
recommends "Type::Tiny::XS" => "0";
|
|
14 |
recommends "Unicode::UTF8" => "0";
|
14 | 15 |
|
15 | 16 |
feature 'accelerate', 'Accelerate Dancer2 app performance with XS modules' => sub {
|
16 | 17 |
requires "URL::Encode::XS" => "0";
|
|
24 | 25 |
requires "Math::Random::ISAAC::XS" => "0";
|
25 | 26 |
requires "MooX::TypeTiny" => "0";
|
26 | 27 |
requires "Type::Tiny::XS" => "0";
|
|
28 |
requires "Unicode::UTF8" => "0";
|
27 | 29 |
};
|
28 | 30 |
|
29 | 31 |
on "test" => sub {
|
131 | 131 |
$bench->report;
|
132 | 132 |
} else {
|
133 | 133 |
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>
|
135 | 135 |
("--" is required before parameters because D1 parses ARGV)
|
136 | 136 |
|
137 | 137 |
Commands:
|