-
-
15 Jan 2016 10:33:43 UTC
- Distribution: Mason-Plugin-WithEncoding
- Module version: 0.2
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (1)
- Testers (242 / 86 / 16)
- Kwalitee
Bus factor: 0- 75.00% Coverage
- License: perl_5
- Perl: v5.12.0
- Activity
24 month- Tools
- Download (20.2KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Mason::Plugin::WithEncoding - Add encoding support to Poet/Mason apps
VERSION
version 0.2
SYNOPSIS
In your Poet config file: # This is important or the first (and *only* the first) request will # not use Plack::Request::WithEncoding server.load_modules: - Mason::Plugin::WithEncoding mason: extra_plugins: - WithEncoding server.encoding.request: UTF-8 server.encoding.response: UTF-8 server.default_content_type: text/html; charset=UTF-8
DESCRIPTION
To decode the request, the plugin loads Plack::Request::WithEncoding and configures it with the encoding specified in
server.encoding.request
. If no such setting is found, the request is not decoded. This matches the default behaviour of Poet/Mason, but is different from Plack::Request::WithEncoding, (which would normally default to UTF-8).Output generated by your Mason templates is encoded according to the setting in
server.encoding.response
. If no such setting is found, the response is not encoded. This is the default behaviour of Poet/Mason.The content-type default header is set according to
server.default_content_type
. If no such setting is found, the default header istext/html
, as in the default Poet/Mason setup. This tells the client what encoding to use when decoding our content, and also (AFAIK) tells the client what encoding to use when sending us data.Output sent through
send_json
is also encoded and the content-type header set accordingly.Caveats
This plugin only works inside a Poet environment.
The
send_json
method added to the Mason request object by Poet always encodes its output as UTF8, which is pretty much always the correct thing to do. But if you are using some other encoding, you'll need to patch this plugin to getsend_json
to use that instead of UTF8.Some background
http://stackoverflow.com/questions/27806684/mason2-wrong-utf8-encoding-with-the-go-method http://stackoverflow.com/questions/5858596/how-to-make-mason2-utf-8-clean https://www.mail-archive.com/mason-users@lists.sourceforge.net/msg03450.html
AUTHOR
Dave Baird <dave@zerofive.co.uk>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by David R. Baird.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Mason::Plugin::WithEncoding, copy and paste the appropriate command in to your terminal.
cpanm Mason::Plugin::WithEncoding
perl -MCPAN -e shell install Mason::Plugin::WithEncoding
For more information on module installation, please visit the detailed CPAN module installation guide.