From ab8410b41dc8628457d372cd8eaccc32783b4146 Mon Sep 17 00:00:00 2001 From: "Enot (ded) Skelly" Date: Fri, 22 May 2026 14:12:47 -0700 Subject: [PATCH] add api response helper --- internal/api/handlers/helpers.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 internal/api/handlers/helpers.go diff --git a/internal/api/handlers/helpers.go b/internal/api/handlers/helpers.go new file mode 100644 index 0000000..2341969 --- /dev/null +++ b/internal/api/handlers/helpers.go @@ -0,0 +1,12 @@ +package handlers + +import ( + "encoding/json" + "net/http" +) + +func respond(w http.ResponseWriter, status int, data any) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + json.NewEncoder(w).Encode(data) +}