Bugzilla – Attachment 94499 Details for
Bug 23859
Cities endpoint not setting the Location header
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23859: Make POST add the Location header on cities endpoint
Bug-23859-Make-POST-add-the-Location-header-on-cit.patch (text/plain), 1.77 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-10-21 19:15:32 UTC
(
hide
)
Description:
Bug 23859: Make POST add the Location header on cities endpoint
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-10-21 19:15:32 UTC
Size:
1.77 KB
patch
obsolete
>From e4ec2b64ceb7a6914eb65743f350911aa5adbf91 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 21 Oct 2019 14:42:28 -0300 >Subject: [PATCH] Bug 23859: Make POST add the Location header on cities > endpoint > >According to the coding guidelines, this endpoint should be adding the >Location header on POST actions. > >To test: >1. Apply the tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/cities.t >=> FAIL: Tests fail! >3. Apply this patch >4. Repeat (1) >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Cities.pm | 6 +++++- > api/v1/swagger/paths/cities.json | 2 +- > 2 files changed, 6 insertions(+), 2 deletions(-) > >diff --git a/Koha/REST/V1/Cities.pm b/Koha/REST/V1/Cities.pm >index 222f7c0015..793880c813 100644 >--- a/Koha/REST/V1/Cities.pm >+++ b/Koha/REST/V1/Cities.pm >@@ -78,7 +78,11 @@ sub add { > return try { > my $city = Koha::City->new( _to_model( $c->validation->param('body') ) ); > $city->store; >- return $c->render( status => 200, openapi => $city->to_api ); >+ $c->res->headers->location( $c->req->url->to_string . '/' . $city->cityid ); >+ return $c->render( >+ status => 201, >+ openapi => $city->to_api >+ ); > } > catch { > if ( $_->isa('DBIx::Class::Exception') ) { >diff --git a/api/v1/swagger/paths/cities.json b/api/v1/swagger/paths/cities.json >index 5779a48651..77ee394af4 100644 >--- a/api/v1/swagger/paths/cities.json >+++ b/api/v1/swagger/paths/cities.json >@@ -84,7 +84,7 @@ > "application/json" > ], > "responses": { >- "200": { >+ "201": { > "description": "City added", > "schema": { > "$ref": "../definitions.json#/city" >-- >2.23.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23859
:
94497
|
94498
|
94499
|
94500
|
94938
|
94939
|
94940