data.go 435 B

1234567891011121314151617181920
  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. package render
  5. import "net/http"
  6. type Data struct {
  7. ContentType string
  8. Data []byte
  9. }
  10. func (r Data) Render(w http.ResponseWriter) error {
  11. if len(r.ContentType) > 0 {
  12. w.Header()["Content-Type"] = []string{r.ContentType}
  13. }
  14. w.Write(r.Data)
  15. return nil
  16. }