MT#60227 handle Accept: application/json header

* if Accept: applicaton/json header is provided for API
  request - the response's Content-Type header is set to
  application/json. The return content in this case is preserved
  as HAL but it's helpful for the clients that only expect
  aplication/json response Content-Type

Change-Id: I8c60da4df7d639f45953d8ace699a59fefc88ddf
mr12.5
Kirill Solomko 11 months ago
parent a46ef5b9e2
commit 6926930b3a

@ -29,9 +29,17 @@ sub auto :Private {
sub end :Private {
my ($self, $c) = @_;
if (my $accept = $c->request->header('Accept')) {
if ($accept eq 'application/json') {
$c->response->content_type($accept);
}
}
if ($self->get_config('log_response')) {
$self->log_response($c);
}
return 1;
}

@ -34,9 +34,17 @@ sub auto :Private {
sub end :Private {
my ($self, $c) = @_;
if (my $accept = $c->request->header('Accept')) {
if ($accept eq 'application/json') {
$c->response->content_type($accept);
}
}
if ($self->get_config('log_response')) {
$self->log_response($c);
}
return 1;
}

Loading…
Cancel
Save