HTTP::Response::Maker - easy HTTP response object maker functions
use HTTP::Response::Maker 'HTTPResponse', ( default_headers => [ 'Content-Type' => 'text/html; charset=utf-8' ], prefix => 'RESPOND_', ); # now you can use functions like RESPOND_OK() or RESPOND_NOT_FOUND()
or
use HTTP::Response::Maker::Exception prefix => 'throw_'; throw_FOUND(Location => '/');
HTTP::Response::Maker provides HTTP response object maker functions. They are named as OK() or NOT_FOUND(), corresponding to the HTTP::Status constant names.
OK()
NOT_FOUND()
Exports HTTP response maker functions to current package.
$impl specifies what functions make. See IMPLEMENTATION.
%args has these keys:
Prefix for exported functions names.
Default HTTP headers in arrayref.
import()'s first argument specifies what type of objects functions generate. Currently it is one of:
import()
Generates an HTTP::Response object.
Generates an arrayref of PSGI response format.
Generates a Plack::Response object.
You can specify subclass of Plack::Response to generate:
use HTTP::Response::Maker 'Plack', class => 'Your::Plack::Response';
Throws an HTTP::Exception.
Exported functions accept arguments in some ways:
my $res = OK; my $res = OK $content; my $res = OK \@headers; my $res = OK \@headers, $content;
motemen <motemen@gmail.com>
HTTP::Status, PSGI, HTTP::Response, HTTP::Exception
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTTP::Response::Maker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Response::Maker
CPAN shell
perl -MCPAN -e shell install HTTP::Response::Maker
For more information on module installation, please visit the detailed CPAN module installation guide.