Skip to content

Commit

Permalink
content_type should be checked only in case of a POST|PUT, accept hav…
Browse files Browse the repository at this point in the history
…e a higher priority than accet_type
  • Loading branch information
fcuny committed May 25, 2010
1 parent 0148a61 commit b51ade1
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/Dancer/Serializer/Mutable.pm
Expand Up @@ -28,23 +28,30 @@ sub _find_content_type {
$params = $request->params;
}

if ( $request->{content_type} ) {
$content_types{ $request->{content_type} } = 3;
}
my $method = $request->method;

if ($method =~ /^(?:POST|PUT)$/) {
if ($request->{content_type}) {
$content_types{$request->{content_type}} = 4;
}

if ( $params && $params->{content_type} ) {
$content_types{ $params->{content_type} } = 2;
if ($params && $params->{content_type}) {
$content_types{$params->{content_type}} = 3;
}
}

if ( $request->{accept} ) {
$content_types{ $request->{accept} } = 1;
if ($request->{accept}) {
$content_types{$request->{accept}} = 2;
}
if ($request->{'accept_type'}) {
$content_types{$request->{accept_type}} = 1;
}

$content_types{'application/json'} = 0;

return [
sort { $content_types{$b} <=> $content_types{$a} }
keys %content_types
keys %content_types
];
}

Expand Down

0 comments on commit b51ade1

Please sign in to comment.