package handlers import "encoding/json" import "net/http" 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 DecodeJSON(r *http.Request, target interface{}) error { return json.NewDecoder(r.Body).Decode(target) }