Haineko::HTTPD::Response - Child class of Plack::Response
Haineko::HTTPD::Response is child class of Plack::Response and contain some wrapper methods.
use Haineko::HTTPD::Response; my $r = Haineko::HTTPD::Response->new; # => isa 'Haineko::HTTPD::Response' my $v = Haineko::HTTPD::Response->mime('text'); # => is 'text/plain; charset=utf-8' $r->text( 200, 'Nyaaaaa' ); # returns [ 200, [ ... ], [ 'Nyaaaaa' ] ] $r->json( 200, { 'neko' => 1 } ); # returns [ 200, [ ... ], [ '{ "neko": 1 }' ] ]
mime( Type )
mime() returns the value of "Content-Type" header for the argument. For example, mime('json') returns 'application/json', mime('text') returns 'text/plain'.
mime()
mime('json')
mime('text')
text( Code, Content )
text() is a wrapper method for _res() method to respond 'text/plain' content.
text()
_res()
json( Code, ArrayRef|HashRef )
json() is a wrapper method for _res() method to respond 'application/json' content. The 2nd argument will be converted to JSON as a string automatically.
json()
_res( Content, Type )
_res() is wrapper method for responding. For example _res( 'Nyaaa', 'text' ) or _res( { 'neko': 2 }, 'json' ).
_res( 'Nyaaa', 'text' )
_res( { 'neko': 2 }, 'json' )
Haineko::HTTPD
https://github.com/azumakuniyuki/Haineko
azumakuniyuki <perl.org [at] azumakuniyuki.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Haineko, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Haineko
CPAN shell
perl -MCPAN -e shell install Haineko
For more information on module installation, please visit the detailed CPAN module installation guide.