add new helper function

This commit is contained in:
Adrian Zürcher
2026-01-21 07:27:50 +01:00
parent 4904589086
commit 84abf6b820

12
utils/http.go Normal file
View File

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