Skip to content

Instantly share code, notes, and snippets.

Created August 10, 2016 00:46
Show Gist options
  • Save anonymous/a60669ad606173f85dece03f54e2f2ba to your computer and use it in GitHub Desktop.
Save anonymous/a60669ad606173f85dece03f54e2f2ba to your computer and use it in GitHub Desktop.
Mojolicious::Plugin::Charset;でエンコーディングとキャラセット分けて指定できるようにする
package Mojolicious::Plugin::Charset;
use Mojo::Base 'Mojolicious::Plugin';
sub register {
my ($self, $app, $conf) = @_;
return unless my $c = $conf->{charset};
return unless my $e = $conf->{encoding};
$app->types->type(html => "text/html;charset=$c");
$app->renderer->encoding($e);
$app->hook(before_dispatch =>
sub { shift->req->default_charset($c)->url->query->charset($c) });
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment