From c1cb85016b9de6454e3811262255b27ee4436722 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 30 Mar 2022 13:45:48 +0200 Subject: [PATCH] Bug 30394: Add x-koha-request-id handling in controllers This patch adds 'x-koha-request-id' to the reserved param names list, and makes the objects.search helper read it and send it back in the response headers. Signed-off-by: Tomas Cohen Arazi --- Koha/REST/Plugin/Objects.pm | 4 ++++ Koha/REST/Plugin/Query.pm | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 86c1d297e0..4a5d29143c 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -182,6 +182,10 @@ shouldn't be called twice in it. $filtered_params = $c->merge_q_params( $filtered_params, $query_params, $result_set ); } + # request sequence id (i.e. 'draw' Datatables parameter) + $c->res->headers->add( 'x-koha-request-id' => $reserved_params->{'x-koha-request-id'} ) + if $reserved_params->{'x-koha-request-id'}; + # If search_limited exists, use it $result_set = $result_set->search_limited, if $result_set->can('search_limited'); diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm index 5603e60294..5875d92a46 100644 --- a/Koha/REST/Plugin/Query.pm +++ b/Koha/REST/Plugin/Query.pm @@ -310,7 +310,7 @@ reference: https://metacpan.org/changes/distribution/JSON-Validator#L14 sub _reserved_words { - my @reserved_words = qw( _match _order_by _order_by[] _page _per_page q query x-koha-query); + my @reserved_words = qw( _match _order_by _order_by[] _page _per_page q query x-koha-query x-koha-request-id ); return \@reserved_words; } -- 2.35.1