Created
August 10, 2016 00:46
-
-
Save anonymous/a60669ad606173f85dece03f54e2f2ba to your computer and use it in GitHub Desktop.
Mojolicious::Plugin::Charset;でエンコーディングとキャラセット分けて指定できるようにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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