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}) +}