This is cool but I think its brittle against real world scenarios:
func (r *Resource) get(w http.ResponseWriter, r *http.Request){
user, err := r.authenticate(req)
if err != nil {
r.WriteJSONErr(w, err)
return
}
var records []*User
if err := r.db.Select("select id, name, created_date from users", &records); err != nil {
r.WriteJSONErr(w, err)
return
}
r.WriteJSON(w, records)
}
You would have to reformat all your function signatures to receive maybe a pointer to populate and return only an error, which could work but meh.