package handlers

import (
	"encoding/json"
	"net/http"
)

func decode(r *http.Request, target interface{}) bool {
	return json.NewDecoder(r.Body).Decode(target) == nil
}
func writeJSON(w http.ResponseWriter, status int, value interface{}) {
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(status)
	_ = json.NewEncoder(w).Encode(value)
}
func writeError(w http.ResponseWriter, status int, message string) {
	writeJSON(w, status, map[string]string{"error": message})
}
