Dancer2
view release on metacpan or search on metacpan
share/skel/default/config.yml view on Meta::CPAN
# Your application's name
appname: "[d2% appname %2d]"
# The default layout to use for your application (located in
# views/layouts/main.tt)
layout: "main"
# when the charset is set to UTF-8 Dancer2 will handle for you
# all the magic of encoding and decoding. You should not care
# about unicode within your app when this setting is set (recommended).
charset: "UTF-8"
# When strict_config is true, Dancer2 will warn you about unknown
# top-level configuration keys, and warn about unknown engine
# configuration options.
strict_config: 1
# === Engines ===
#
# NOTE: All the engine configurations need to be under a single "engines:"
share/skel/tutorial/config.yml view on Meta::CPAN
# Your application's name
appname: "[d2% appname %2d]"
# The default layout to use for your application (located in
# views/layouts/main.tt)
layout: "main"
# when the charset is set to UTF-8 Dancer2 will handle for you
# all the magic of encoding and decoding. You should not care
# about unicode within your app when this setting is set (recommended).
charset: "UTF-8"
# === Engines ===
#
# NOTE: All the engine configurations need to be under a single "engines:"
# key. If you uncomment engine configurations below, make sure to delete
# all "engines:" lines except the first. Otherwise, only the last
# "engines:" block will take effect.
# template engine
t/charset_server.t view on Meta::CPAN
use Dancer2;
get '/name/:name' => sub {
"Your name: " . params->{name};
};
post '/name' => sub {
"Your name: " . params->{name};
};
get '/unicode' => sub {
"cyrillic shcha \x{0429}",;
};
get '/symbols' => sub {
'â â â â â â â â';
};
set charset => 'utf-8';
}
t/charset_server.t view on Meta::CPAN
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( POST "/name", [ name => 'vasya'] );
is $res->content_type, 'text/html';
ok $res->content_type_charset
; # we always have charset if the setting is set
is $res->content, 'Your name: vasya';
$res = $cb->( GET "/unicode" );
is $res->content_type, 'text/html';
is $res->content_type_charset, 'UTF-8';
is $res->content, Encode::encode( 'utf-8', "cyrillic shcha \x{0429}" );
$res = $cb->( GET "/symbols" );
is $res->content_type, 'text/html';
is $res->content_type_charset, 'UTF-8';
is $res->content, Encode::encode( 'utf-8', "â â â â â â â â" );
};
t/request.t view on Meta::CPAN
undef,
{ method => 'POST' },
);
is $req->path, '/new/path', 'path is changed';
is $req->method, 'POST', 'method is changed';
is_deeply scalar( $req->params ), { foo => 'bar', number => 42 },
'params are not touched';
note "testing unicode params";
$env = {
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/',
'PATH_INFO' => '/',
'QUERY_STRING' => "M%C3%BCller=L%C3%BCdenscheid",
};
$req = Dancer2::Core::Request->new( env => $env );
is_deeply scalar( $req->params ), { "M\N{U+00FC}ller", "L\N{U+00FC}denscheid" },
'multi byte unicode chars work in param keys and values';
{
note "testing private _decode not to mangle hash";
my @warnings;
local $SIG{__WARN__} = sub {
push @warnings, @_;
};
my $h = { zzz => undef, };
for ( 'aaa' .. 'fff' ) {
$h->{$_} = $_;
( run in 1.608 second using v1.01-cache-2.11-cpan-39bf76dae61 )