http urls monitor.

yaml.go 611B

12345678910111213141516171819202122232425262728293031323334
  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 (
  6. "net/http"
  7. "gopkg.in/yaml.v2"
  8. )
  9. type YAML struct {
  10. Data interface{}
  11. }
  12. var yamlContentType = []string{"application/x-yaml; charset=utf-8"}
  13. func (r YAML) Render(w http.ResponseWriter) error {
  14. r.WriteContentType(w)
  15. bytes, err := yaml.Marshal(r.Data)
  16. if err != nil {
  17. return err
  18. }
  19. w.Write(bytes)
  20. return nil
  21. }
  22. func (r YAML) WriteContentType(w http.ResponseWriter) {
  23. writeContentType(w, yamlContentType)
  24. }