From 84abf6b8206ffb75a7927ea7482098667f836b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Z=C3=BCrcher?= Date: Wed, 21 Jan 2026 07:27:50 +0100 Subject: [PATCH] add new helper function --- utils/http.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils/http.go diff --git a/utils/http.go b/utils/http.go new file mode 100644 index 0000000..f8d947b --- /dev/null +++ b/utils/http.go @@ -0,0 +1,12 @@ +package utils + +import ( + "encoding/json" + "net/http" +) + +func SendJSONError(w http.ResponseWriter, message string, code int) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(code) + json.NewEncoder(w).Encode(map[string]string{"error": message}) +}