mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-06 14:26:22 +00:00
Better headers
This commit is contained in:
parent
7c1bae60c9
commit
2442589982
@ -1926,6 +1926,7 @@ func (h *Handler) sendResponseWithOptions(w common.ResponseWriter, data interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return data as-is without wrapping in common.Response
|
// Return data as-is without wrapping in common.Response
|
||||||
|
w.SetHeader("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
if err := w.WriteJSON(data); err != nil {
|
if err := w.WriteJSON(data); err != nil {
|
||||||
logger.Error("Failed to write JSON response: %v", err)
|
logger.Error("Failed to write JSON response: %v", err)
|
||||||
@ -2028,6 +2029,7 @@ func (h *Handler) sendError(w common.ResponseWriter, statusCode int, code, messa
|
|||||||
"_error": errorMsg,
|
"_error": errorMsg,
|
||||||
"_retval": 1,
|
"_retval": 1,
|
||||||
}
|
}
|
||||||
|
w.SetHeader("Content-Type", "application/json")
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
if jsonErr := w.WriteJSON(response); jsonErr != nil {
|
if jsonErr := w.WriteJSON(response); jsonErr != nil {
|
||||||
logger.Error("Failed to write JSON error response: %v", jsonErr)
|
logger.Error("Failed to write JSON error response: %v", jsonErr)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user