1// Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2// Use of this source code is governed by a MIT style 3// license that can be found in the LICENSE file. 4 5package render 6 7import "net/http" 8 9type Data struct { 10 ContentType string 11 Data []byte 12} 13 14// Render (Data) writes data with custom ContentType. 15func (r Data) Render(w http.ResponseWriter) (err error) { 16 r.WriteContentType(w) 17 _, err = w.Write(r.Data) 18 return 19} 20 21func (r Data) WriteContentType(w http.ResponseWriter) { 22 writeContentType(w, []string{r.ContentType}) 23} 24