2017-02-19 07:04:00 +00:00
|
|
|
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package render
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
type Render interface {
|
|
|
|
Render(http.ResponseWriter) error
|
2017-03-29 01:21:31 +00:00
|
|
|
WriteContentType(w http.ResponseWriter)
|
2017-02-19 07:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ Render = JSON{}
|
|
|
|
_ Render = IndentedJSON{}
|
2017-07-15 03:23:57 +00:00
|
|
|
_ Render = SecureJSON{}
|
2017-02-19 07:04:00 +00:00
|
|
|
_ Render = XML{}
|
|
|
|
_ Render = String{}
|
|
|
|
_ Render = Redirect{}
|
|
|
|
_ Render = Data{}
|
|
|
|
_ Render = HTML{}
|
|
|
|
_ HTMLRender = HTMLDebug{}
|
|
|
|
_ HTMLRender = HTMLProduction{}
|
|
|
|
_ Render = YAML{}
|
2017-03-29 01:21:31 +00:00
|
|
|
_ Render = MsgPack{}
|
2017-02-19 07:04:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func writeContentType(w http.ResponseWriter, value []string) {
|
|
|
|
header := w.Header()
|
|
|
|
if val := header["Content-Type"]; len(val) == 0 {
|
|
|
|
header["Content-Type"] = value
|
|
|
|
}
|
|
|
|
}
|