The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Haineko::HTTPD::Response - Child class of Plack::Response

DESCRIPTION

Haineko::HTTPD::Response is child class of Plack::Response and contain some wrapper methods.

SYNOPSIS

    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 }' ] ]

CLASS METHODS

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'.

INSTANCE METHODS

text( Code, Content )

text() is a wrapper method for _res() method to respond 'text/plain' content.

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.

_res( Content, Type )

_res() is wrapper method for responding. For example _res( 'Nyaaa', 'text' ) or _res( { 'neko': 2 }, 'json' ).

SEE ALSO

Haineko::HTTPD

REPOSITORY

https://github.com/azumakuniyuki/Haineko

AUTHOR

azumakuniyuki <perl.org [at] azumakuniyuki.org>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.