package handler import ( "encoding/json" "net/http" ) func writeJSON(w http.ResponseWriter, code int, v any) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(code) json.NewEncoder(w).Encode(v) } func writeError(w http.ResponseWriter, code int, msg string) { writeJSON(w, code, map[string]string{"error": msg}) } func decodeJSON(r *http.Request, v any) error { return json.NewDecoder(r.Body).Decode(v) }