TT#34567 Use already created hal links for embedded and Location

Change-Id: I3e32ecb89cc9b6966dbe5caa2fa7a26054c7b23b
changes/22/20122/13
Irina Peshinskaya 8 years ago
parent 05c2708832
commit 8eec82f1bb

@ -1382,12 +1382,8 @@ sub return_representation_post{
$response //= HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new(
$hal->http_headers,
), $hal->as_json);
$c->response->header(
Location => sprintf('/%s%s',
$c->request->path,
$self->get_item_id(
$c,$item, undef, undef, { purpose => 'hal_links_href' })
));
my ($self_hal_link) = grep { $_->relation->as_string eq 'self' } @{$hal->links};
$c->response->header( Location => $self_hal_link->href->as_string );
}
if ('minimal' eq $preference || !$response) {

@ -207,17 +207,7 @@ sub get {
my @items = 'ARRAY' eq ref $items ? @$items : $items->all;
for my $item (@items) {
push @embedded, $self->hal_from_item($c, $item, $form, {});
#TODO: replace hal_links_href by separated method that utilize get_item_id.
push @links, Data::HAL::Link->new(
relation => 'ngcp:'.$self->resource_name,
href => $self->apply_mandatory_parameters($c, 'item',
sprintf(
'/%s%s',
$c->request->path,
$self->get_item_id($c, $item)
), $item, $resource
),
);
push @links, grep { $_->relation->_original eq 'ngcp:'.$self->resource_name } @{$embedded[-1]->links};
}
push @links,
Data::HAL::Link->new(

Loading…
Cancel
Save