move all REST responses except HEAD to JSON

writeJSON includes a call to w.Header().Set(); this must come before the call to w.WriteHeader().