gin-gonic / gin
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

5
package render
6

7
import "net/http"
8

9
// Data contains ContentType and bytes data.
10
type Data struct {
11
	ContentType string
12
	Data        []byte
13
}
14

15
// Render (Data) writes data with custom ContentType.
16
func (r Data) Render(w http.ResponseWriter) (err error) {
17 151
	r.WriteContentType(w)
18 151
	_, err = w.Write(r.Data)
19 151
	return
20
}
21

22
// WriteContentType (Data) writes custom ContentType.
23
func (r Data) WriteContentType(w http.ResponseWriter) {
24 151
	writeContentType(w, []string{r.ContentType})
25
}

Read our documentation on viewing source code .

Loading