Render (ProtoBuf) marshals the given interface object and writes data with custom ContentType.
(w http.ResponseWriter)
| 19 | |
| 20 | // Render (ProtoBuf) marshals the given interface object and writes data with custom ContentType. |
| 21 | func (r ProtoBuf) Render(w http.ResponseWriter) error { |
| 22 | r.WriteContentType(w) |
| 23 | |
| 24 | bytes, err := proto.Marshal(r.Data.(proto.Message)) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | |
| 29 | _, err = w.Write(bytes) |
| 30 | return err |
| 31 | } |
| 32 | |
| 33 | // WriteContentType (ProtoBuf) writes ProtoBuf ContentType. |
| 34 | func (r ProtoBuf) WriteContentType(w http.ResponseWriter) { |
nothing calls this directly
no test coverage detected