From 1dada9b5b83465062a0bf531aa398befb52d1040 Mon Sep 17 00:00:00 2001 From: pablomendezroyo Date: Thu, 12 Dec 2024 10:16:25 +0100 Subject: [PATCH] Append status code message to response --- internal/adapters/api/api_adapter.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/adapters/api/api_adapter.go b/internal/adapters/api/api_adapter.go index fee4833..e5ec49e 100644 --- a/internal/adapters/api/api_adapter.go +++ b/internal/adapters/api/api_adapter.go @@ -373,5 +373,8 @@ func (h *APIHandler) GetExitRequests(w http.ResponseWriter, r *http.Request) { func writeErrorResponse(w http.ResponseWriter, message string, statusCode int) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(statusCode) - json.NewEncoder(w).Encode(map[string]string{"error": message}) + json.NewEncoder(w).Encode(map[string]interface{}{ + "error": message, + "status_code": statusCode, + }) }