Render (Data) writes data with custom ContentType.
(w http.ResponseWriter)
| 17 | |
| 18 | // Render (Data) writes data with custom ContentType. |
| 19 | func (r Data) Render(w http.ResponseWriter) (err error) { |
| 20 | r.WriteContentType(w) |
| 21 | if len(r.Data) > 0 { |
| 22 | w.Header().Set("Content-Length", strconv.Itoa(len(r.Data))) |
| 23 | } |
| 24 | _, err = w.Write(r.Data) |
| 25 | return |
| 26 | } |
| 27 | |
| 28 | // WriteContentType (Data) writes custom ContentType. |
| 29 | func (r Data) WriteContentType(w http.ResponseWriter) { |