http urls monitor.

data.go 541B

123456789101112131415161718192021222324
  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. // Render (Data) writes data with custom ContentType.
  11. func (r Data) Render(w http.ResponseWriter) (err error) {
  12. r.WriteContentType(w)
  13. _, err = w.Write(r.Data)
  14. return
  15. }
  16. func (r Data) WriteContentType(w http.ResponseWriter) {
  17. writeContentType(w, []string{r.ContentType})
  18. }