(w http.ResponseWriter, r *http.Request, result interface{}, responseCode int)
| 57 | } |
| 58 | |
| 59 | func (s *Server) JSONResponseCode(w http.ResponseWriter, r *http.Request, result interface{}, responseCode int) { |
| 60 | body, err := json.Marshal(result) |
| 61 | if err != nil { |
| 62 | w.WriteHeader(http.StatusInternalServerError) |
| 63 | s.logger.Error("JSON marshal failed", zap.Error(err)) |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 68 | w.Header().Set("X-Content-Type-Options", "nosniff") |
| 69 | w.WriteHeader(responseCode) |
| 70 | w.Write(prettyJSON(body)) |
| 71 | } |
| 72 | |
| 73 | func (s *Server) ErrorResponse(w http.ResponseWriter, r *http.Request, span trace.Span, error string, code int) { |
| 74 | data := struct { |
no test coverage detected