Bug 38929: Make POST endpoints return the `Location` header
This patch makes the POST endpoints missing the Location header return
it.
Some endpoints I skipped:
* /patrons/account/credits (doesn't have a GET route to point to)
* /patrons/account/debits (doesn't have a GET route to point to)
To test:
1. Apply the regression tests
2. Run:
$ ktd --shell
k$ prove t/db_dependent/api/v1/authorities.t \
t/db_dependent/api/v1/biblios.t \
t/db_dependent/api/v1/clubs_holds.t \
t/db_dependent/api/v1/holds.t \
t/db_dependent/api/v1/ill_batchstatuses.t \
t/db_dependent/api/v1/import_batch_profiles.t \
t/db_dependent/api/v1/transfer_limits.t
=> FAIL: Tests fail! The endpoints don't return the header!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
de1b28d2f6
commit
eab06ab69b
|
|
@ -370,6 +370,10 @@ sub add_item {
|
|||
|
||||
$item->store->discard_changes;
|
||||
|
||||
my $base_url = $c->req->url->to_string;
|
||||
$base_url =~ s|/biblios/\d+||;
|
||||
$c->res->headers->location( $base_url . '/' . $item->id );
|
||||
|
||||
$c->render(
|
||||
status => 201,
|
||||
openapi => $c->objects->to_api($item),
|
||||
|
|
@ -719,6 +723,8 @@ sub add {
|
|||
);
|
||||
}
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $biblio_id );
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => { id => $biblio_id }
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ sub add {
|
|||
}
|
||||
);
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $club_hold->id );
|
||||
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $c->objects->to_api($club_hold),
|
||||
|
|
|
|||
|
|
@ -216,6 +216,8 @@ sub add {
|
|||
|
||||
my $hold = Koha::Holds->find($hold_id);
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $hold_id );
|
||||
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $c->objects->to_api($hold),
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ sub add {
|
|||
openapi => $return
|
||||
);
|
||||
} else {
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $status->code );
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $status
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ sub add {
|
|||
|
||||
return try {
|
||||
my $profile = Koha::ImportBatchProfile->new_from_api( $body )->store;
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $profile->id );
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $c->objects->to_api($profile),
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ sub add {
|
|||
Koha::Exceptions::TransferLimit::Duplicate->throw();
|
||||
}
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $transfer_limit->id );
|
||||
|
||||
return $c->render(
|
||||
status => 201,
|
||||
openapi => $c->objects->to_api($transfer_limit),
|
||||
|
|
|
|||
Loading…
Reference in New Issue