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