my %map = (
json => 'application/json',
xml => 'application/xml',
);
builder {
enable 'SetAccept', from => 'suffix', mapping => \%map;
$app;
};
# now /foo.json behaves as /fo
o, with Accept: application/json
# or
builder {
enable 'SetAccept', from => 'param', param => 'format', mapping => \%map;
$app;
};
# now /foo?format=xml behaves as /foo, with Accept:
request
URI. It can extract from either the suffix of the path (ex. /foo.json) or
from the query string (ex. /foo?format=json) for HEAD and GET requests. The
value is looked up in a mapping table an