Nephiaで日本語の巻
# アクセスすると以下の様なエラーログを吐いて 500 internal server error になってしまう
--
Body must be bytes and should not contain wide characters (UTF-8 strings) at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Middleware/Lint.pm line 153
Plack::Middleware::Lint::validate_res('Plack::Middleware::Lint=HASH(0x7fc1329aacc0)', 'ARRAY(0x7fc132b37840)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Middleware/Lint.pm line 25
Plack::Middleware::Lint::call('Plack::Middleware::Lint=HASH(0x7fc1329aacc0)', 'HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Component.pm line 39
Plack::Middleware::StackTrace::__ANON__ at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Try/Tiny.pm line 71
eval {...} at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Try/Tiny.pm line 67
Plack::Middleware::StackTrace::call('Plack::Middleware::StackTrace=HASH(0x7fc132acb5d8)', 'HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Component.pm line 39
Plack::Component::__ANON__('HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Middleware/AccessLog.pm line 28
Plack::Middleware::AccessLog::call('Plack::Middleware::AccessLog=HASH(0x7fc132acc0a0)', 'HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Component.pm line 39
Plack::Component::__ANON__('HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Middleware/ContentLength.pm line 10
Plack::Middleware::ContentLength::call('Plack::Middleware::ContentLength=HASH(0x7fc132b2f258)', 'HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Component.pm line 39
Plack::Component::__ANON__('HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Util.pm line 142
eval {...} at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Util.pm line 142
Plack::Util::run_app('CODE(0x7fc132b2f180)', 'HASH(0x7fc132b269e8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/HTTP/Server/PSGI.pm line 167
HTTP::Server::PSGI::handle_connection('HTTP::Server::PSGI=HASH(0x7fc132acb5f0)', 'HASH(0x7fc132b269e8)', 'IO::Socket::INET=GLOB(0x7fc132b01c70)', 'CODE(0x7fc132b2f180)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/HTTP/Server/PSGI.pm line 127
HTTP::Server::PSGI::accept_loop('HTTP::Server::PSGI=HASH(0x7fc132acb5f0)', 'CODE(0x7fc132acbec0)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/HTTP/Server/PSGI.pm line 55
HTTP::Server::PSGI::run('HTTP::Server::PSGI=HASH(0x7fc132acb5f0)', 'CODE(0x7fc132acbec0)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Handler/HTTP/Server/PSGI.pm line 14
Plack::Handler::HTTP::Server::PSGI::run('Plack::Handler::Standalone=HASH(0x7fc132b2f4e0)', 'CODE(0x7fc132acbec0)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Loader.pm line 84
Plack::Loader::run('Plack::Loader=HASH(0x7fc1328444d8)', 'Plack::Handler::Standalone=HASH(0x7fc132b2f4e0)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Plack/Runner.pm line 267
Plack::Runner::run('Plack::Runner=HASH(0x7fc1328298c8)') called at /Users/jun/perl5/perlbrew/perls/perl-5.16.1/bin/plackup line 10
# eg/lib/MyApp/Root.pm を少し改造
package MyApp::Root;
use strict;
use warnings;
use Encode;
use Nephia;
path '/' => sub {
use utf8;
my $fuga = decode_utf8('あかさたな');
return {
title => encode( 'UTF-8', $fuga ),
template => 'hoge.tx',
};
};
1;