From 9453fab91250e5dcf61cc421ad1699ab5a5339d6 Mon Sep 17 00:00:00 2001 From: Siesta <124433727+siestaw@users.noreply.github.com> Date: Mon, 28 Jul 2025 21:13:20 +0200 Subject: [PATCH] feat: add http status code to responses --- cmd/internal/models/models.go | 1 + cmd/utils/utils.go | 1 + 2 files changed, 2 insertions(+) diff --git a/cmd/internal/models/models.go b/cmd/internal/models/models.go index 9c87f8b..810c094 100644 --- a/cmd/internal/models/models.go +++ b/cmd/internal/models/models.go @@ -17,6 +17,7 @@ type Config struct { } type HTTPResponse struct { + Status int `json:"status"` Success bool `json:"success"` Error string `json:"error,omitempty"` Timestamp string `json:"timestamp"` diff --git a/cmd/utils/utils.go b/cmd/utils/utils.go index fbfc0d9..f14f194 100644 --- a/cmd/utils/utils.go +++ b/cmd/utils/utils.go @@ -53,6 +53,7 @@ func WriteJSONResponse(w http.ResponseWriter, statusCode int, res models.HTTPRes w.Header().Set("Content-Type", "application/json") w.WriteHeader(statusCode) + res.Status = statusCode res.Timestamp = time.Now().UTC().Format(time.RFC3339) json.NewEncoder(w).Encode(res)