(w http.ResponseWriter, code string, errs []string)
| 363 | } |
| 364 | |
| 365 | func SetStatusWithErrors(w http.ResponseWriter, code string, errs []string) { |
| 366 | var qr queryRes |
| 367 | ext := make(map[string]interface{}) |
| 368 | ext["code"] = code |
| 369 | for _, err := range errs { |
| 370 | qr.Errors = append(qr.Errors, &GqlError{Message: err, Extensions: ext}) |
| 371 | } |
| 372 | if js, err := json.Marshal(qr); err == nil { |
| 373 | if _, err := w.Write(js); err != nil { |
| 374 | glog.Errorf("Error while writing: %+v", err) |
| 375 | } |
| 376 | } else { |
| 377 | Panic(errors.Errorf("Unable to marshal: %+v", qr)) |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | // SetHttpStatus is similar to SetStatus but sets a proper HTTP status code |
| 382 | // in the response instead of always returning HTTP 200 (OK). |
no test coverage detected