From 1261960e97a06f800139e6642715e206785ff743 Mon Sep 17 00:00:00 2001 From: Hein Date: Fri, 21 Nov 2025 12:15:07 +0200 Subject: [PATCH] Ability to handle multiple x-custom- headers --- pkg/restheadspec/headers.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/restheadspec/headers.go b/pkg/restheadspec/headers.go index c9691c8..b6488d5 100644 --- a/pkg/restheadspec/headers.go +++ b/pkg/restheadspec/headers.go @@ -162,9 +162,17 @@ func (h *Handler) parseOptionsFromHeaders(r common.Request, model interface{}) E case strings.HasPrefix(key, "x-searchcols"): options.SearchColumns = h.parseCommaSeparated(decodedValue) case strings.HasPrefix(key, "x-custom-sql-w"): - options.CustomSQLWhere = decodedValue + if options.CustomSQLWhere != "" { + options.CustomSQLWhere = fmt.Sprintf("%s AND (%s)", options.CustomSQLWhere, decodedValue) + } else { + options.CustomSQLWhere = decodedValue + } case strings.HasPrefix(key, "x-custom-sql-or"): - options.CustomSQLOr = decodedValue + if options.CustomSQLOr != "" { + options.CustomSQLOr = fmt.Sprintf("%s OR (%s)", options.CustomSQLOr, decodedValue) + } else { + options.CustomSQLOr = decodedValue + } // Joins & Relations case strings.HasPrefix(key, "x-preload"): @@ -226,6 +234,7 @@ func (h *Handler) parseOptionsFromHeaders(r common.Request, model interface{}) E case strings.HasPrefix(key, "x-cql-sel-"): colName := strings.TrimPrefix(key, "x-cql-sel-") options.ComputedQL[colName] = decodedValue + case strings.HasPrefix(key, "x-distinct"): options.Distinct = strings.EqualFold(decodedValue, "true") case strings.HasPrefix(key, "x-skipcount"):