mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-01-03 10:24:26 +00:00
Add clarifying comments about X-No-Data-Found header timing
- Added comments explaining why X-No-Data-Found is set before normalization - Header reflects database query result, not final response format - Clarifies that normalizeResultArray doesn't affect header logic - All tests passing Co-authored-by: warkanum <208308+warkanum@users.noreply.github.com>
This commit is contained in:
@@ -2216,6 +2216,8 @@ func (h *Handler) sendFormattedResponse(w common.ResponseWriter, data interface{
|
||||
}
|
||||
|
||||
// Calculate data length after nil conversion
|
||||
// Note: This is done BEFORE normalization because X-No-Data-Found indicates
|
||||
// whether data was found in the database, not the final response format
|
||||
dataLen := reflection.Len(data)
|
||||
|
||||
// Add X-No-Data-Found header when no records were found
|
||||
@@ -2223,6 +2225,9 @@ func (h *Handler) sendFormattedResponse(w common.ResponseWriter, data interface{
|
||||
w.SetHeader("X-No-Data-Found", "true")
|
||||
}
|
||||
|
||||
// Apply normalization after header is set
|
||||
// normalizeResultArray may convert single-element arrays to objects,
|
||||
// but the X-No-Data-Found header reflects the original query result
|
||||
if options.SingleRecordAsObject {
|
||||
data = h.normalizeResultArray(data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user