mirror of https://github.com/gin-gonic/gin.git
25 lines
652 B
Go
25 lines
652 B
Go
package common
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
//WriteContentType set the content-type header
|
|
func WriteContentType(w http.ResponseWriter, value []string) {
|
|
header := w.Header()
|
|
if val := header["Content-Type"]; len(val) == 0 {
|
|
header["Content-Type"] = value
|
|
}
|
|
}
|
|
|
|
// Render interface is to be implemented by JSON, XML, HTML, YAML and so on.
|
|
type Render interface {
|
|
// Render writes data with custom ContentType.
|
|
Render(http.ResponseWriter) error
|
|
// WriteContentType writes custom ContentType.
|
|
WriteContentType(w http.ResponseWriter)
|
|
}
|
|
|
|
//List hold the defined render (obj, options)
|
|
var List = map[string]func(interface{}, map[string]string) Render{}
|