package httputil import ( "encoding/json" "net/http" ) type H map[string]interface{} func WriteJSON(w http.ResponseWriter, data interface{}) { w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(data) if err != nil { panic(err) } } func ReadJSON(r *http.Request, data interface{}) error { return json.NewDecoder(r.Body).Decode(data) }