-
-
Save masaru-b-cl/fe7e763de65c6067b4a33326b058bb85 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($e)->url->query->charset($e) }); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment