Open KES777 opened 6 years ago
Route default format take precedence over requested format, even Accept header
Accept header
$ perl -Mojo -E 'a("/" => {format => "txt"} => sub { $_->render(text => $_->accepts("", "json", "txt") . "\n") })->start' get /?format=json txt
By setting up {format} for route:
get '/route' => { format => 'txt' }
or for an application:
$app->defaults( format => 'xml' )
we can define supported formats for response:
get '/route' => { format => [qw(xml json)] } $app->defaults ({ format => [qw(xml json)] })
Also this will allow us do content negotiation more accurate. See new format helper
format
Summary
Route default format take precedence over requested format, even
Accept header
Motivation
By setting up {format} for route:
or for an application:
we can define supported formats for response:
Also this will allow us do content negotiation more accurate. See new
format
helper