Dancer-Plugin-Negotiate
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Negotiate.pm view on Meta::CPAN
package Dancer::Plugin::Negotiate;
use Modern::Perl;
use Carp 'croak';
use Dancer ':syntax';
use Dancer::Plugin;
use HTTP::Negotiate ();
=head1 NAME
Dancer::Plugin::Negotiate - Content negotiation plugin for Dancer
=head1 VERSION
Version 0.031
=cut
our $VERSION = '0.031';
=head1 SYNOPSIS
use Dancer::Plugin::Negotiate;
$variant = choose_variant(
var1 => {
Quality => 1.000,
Type => 'text/html',
Charset => 'iso-8859-1',
Language => 'en',
Size => 3000
},
var2 => {
Quality => 0.950,
Type => 'text/plain',
Charset => 'us-ascii',
Language => 'no',
Size => 400
},
var3 => {
Quality => 0.3,
Type => 'image/gif',
Size => 43555
}
); # returns 'var1' or 'var2' or 'var3' or undef
=head1 DESCRIPTION
This module is a wrapper for L<HTTP::Negotiate>.
=head1 KEYWORDS
=head2 C<< choose_variant(%variants) >>
C<%options> is a hash like this:
%variants = (
$identifier => \%options
)
The key C<$identifier> is a string that will be returned by C<choose_variant()>.
Valid keywords of hashref C<\%options>:
( run in 1.009 second using v1.01-cache-2.11-cpan-5837b0d9d2c )