Dancer::Headers - Wrapper to handle request headers
use Dancer::Headers; # $headers may be either an ARRAY of key-value pairs, or # an HTTP::Headers object. $dh = Dancer::Headers->new(headers => $headers); # $dh is now a normalized object, which lets the user do: # $dh->get('Some-Header');
This class implements a wrapper that can provide a common interface to access headers, no matter what their origin is.
When the Dancer application is ran under Plack, the headers are accessed via Plack::Request, which returns a HTTP::Headers object. When under the standalone server (powered by HTTP::Server::Simple::PSGI, the headers are sent as an array.
Dancer::Headers takes care of normalizing those two kind of data structure into a singe object.
Returns the value of the given $header.
ARRAY references are stored for headers with multiple values. When get is called in a scalar context on such entries, it returns the first value stored, if called in list context, it returns all the values.
$headers = Dancer::Headers->new([foo => 1, foo => 2]); my $first = $headers->get('foo'); # 1 my @all = $headers->get('foo'); # (1, 2)
Returns the whole normalized HASH reference.
This module as been writen by Alexis Sukrieh
Dancer
To install Dancer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer
CPAN shell
perl -MCPAN -e shell install Dancer
For more information on module installation, please visit the detailed CPAN module installation guide.