Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
easy HTTP response object maker functions
Perl
tree: b4b8be7986

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/HTTP/Response
t
xt
.gitignore
.shipit
Changes
MANIFEST.SKIP
Makefile.PL
README.md

README.md

NAME

HTTP::Response::Maker - easy HTTP response object maker functions

SYNOPSIS

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 => '/');

DESCRIPTION

HTTP::Response::Maker provides HTTP response object maker functions. They are named as OK() or NOT_FOUND(), corresponding to the HTTP::Status constant names.

USAGE

use HTTP::Response::Maker $impl, %args;

Exports HTTP response maker functions to current package.

$impl specifies what functions make. See IMPLEMENTATION.

%args has these keys:

  • prefix => ''

Prefix for exported functions names.

  • default_headers => \@HTTP::Response::Maker::DefaultHeaders

Default HTTP headers in arrayref.

IMPLEMENTATION

import()'s first argument specifies what type of objects functions generate. Currently it is one of:

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.

FUNCTION ARGS

Exported functions accept arguments in some ways:

my $res = OK;
my $res = OK $content;
my $res = OK \@headers;
my $res = OK \@headers, $content;

AUTHOR

motemen motemen@gmail.com

SEE ALSO

HTTP::Status, PSGI, HTTP::Response, HTTP::Exception

LICENSE

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

Something went wrong with that request. Please try again.