mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-06 14:26:22 +00:00
Ability to handle multiple x-custom- headers
This commit is contained in:
parent
76bbf33db2
commit
1261960e97
@ -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"):
|
||||
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"):
|
||||
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"):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user