writeJSON 写入JSON响应
(w http.ResponseWriter, status int, data interface{})
| 307 | |
| 308 | // writeJSON 写入JSON响应 |
| 309 | func writeJSON(w http.ResponseWriter, status int, data interface{}) { |
| 310 | w.Header().Set("Content-Type", "application/json") |
| 311 | w.WriteHeader(status) |
| 312 | json.NewEncoder(w).Encode(data) |
| 313 | } |