MT#3997 Return JSON on precondition failures.

agranig/rest
Andreas Granig 12 years ago
parent 0fb58d2668
commit fd19cf79c1

@ -119,10 +119,7 @@ sub PATCH :Allow {
last unless $self->resource_exists($c, contact => $contact);
$entity = JSON::decode_json($self->hal_from_contact($contact)->as_json);
} else {
$c->response->status(HTTP_PRECONDITION_FAILED);
$c->response->header('Content-Language' => 'en');
$c->response->content_type('application/xhtml+xml');
$c->stash(template => 'api/precondition_failed.tt', entity_name => 'contact');
$self->error($c, HTTP_PRECONDITION_FAILED, "This 'contact' entity cannot be found, it is either expired or does not exist. Fetch a fresh one.");
last;
}
}
@ -246,10 +243,7 @@ sub PUT :Allow {
last unless $self->resource_exists($c, contact => $contact);
$entity = JSON::decode_json($self->hal_from_contact($contact)->as_json);
} else {
$c->response->status(HTTP_PRECONDITION_FAILED);
$c->response->header('Content-Language' => 'en');
$c->response->content_type('application/xhtml+xml');
$c->stash(template => 'api/precondition_failed.tt', entity_name => 'contact');
$self->error($c, HTTP_PRECONDITION_FAILED, "This 'contact' entity cannot be found, it is either expired or does not exist. Fetch a fresh one.");
last;
}
}

@ -121,10 +121,7 @@ sub PATCH :Allow {
last unless $self->resource_exists($c, contract => $contract);
$entity = JSON::decode_json($self->hal_from_contract($contract)->as_json);
} else {
$c->response->status(HTTP_PRECONDITION_FAILED);
$c->response->header('Content-Language' => 'en');
$c->response->content_type('application/xhtml+xml');
$c->stash(template => 'api/precondition_failed.tt', entity_name => 'contract');
$self->error($c, HTTP_PRECONDITION_FAILED, "This 'contract' entity cannot be found, it is either expired or does not exist. Fetch a fresh one.");
last;
}
}
@ -233,10 +230,7 @@ sub PUT :Allow {
last unless $self->resource_exists($c, contract => $contract);
$entity = JSON::decode_json($self->hal_from_contract($contract)->as_json);
} else {
$c->response->status(HTTP_PRECONDITION_FAILED);
$c->response->header('Content-Language' => 'en');
$c->response->content_type('application/xhtml+xml');
$c->stash(template => 'api/precondition_failed.tt', entity_name => 'contract');
$self->error($c, HTTP_PRECONDITION_FAILED, "This 'contract' entity cannot be found, it is either expired or does not exist. Fetch a fresh one.");
last;
}
}

Loading…
Cancel
Save