This commit is contained in:
2026-04-22 18:23:19 +02:00
commit e3e85e4a44
19 changed files with 1273 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package httputil
import (
"encoding/json"
"net/http"
)
func WriteJSON(w http.ResponseWriter, status int, v any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(v)
}
func WriteError(w http.ResponseWriter, status int, msg string) {
WriteJSON(w, status, map[string]string{"error": msg})
}