2014-08-29 17:49:50 +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.
|
|
|
|
|
2014-07-15 15:41:56 +00:00
|
|
|
package render
|
|
|
|
|
2015-05-07 10:44:52 +00:00
|
|
|
import "net/http"
|
2015-03-08 16:50:58 +00:00
|
|
|
|
2015-05-07 10:44:52 +00:00
|
|
|
type Render interface {
|
2015-06-04 03:25:21 +00:00
|
|
|
Render(http.ResponseWriter) error
|
2017-01-09 15:24:48 +00:00
|
|
|
WriteContentType(w http.ResponseWriter)
|
2015-05-07 10:44:52 +00:00
|
|
|
}
|
2014-07-15 15:41:56 +00:00
|
|
|
|
|
|
|
var (
|
2015-05-18 13:45:24 +00:00
|
|
|
_ Render = JSON{}
|
|
|
|
_ Render = IndentedJSON{}
|
2017-07-07 17:21:30 +00:00
|
|
|
_ Render = SecureJSON{}
|
2018-04-26 03:52:19 +00:00
|
|
|
_ Render = JsonpJSON{}
|
2015-05-18 13:45:24 +00:00
|
|
|
_ Render = XML{}
|
|
|
|
_ Render = String{}
|
|
|
|
_ Render = Redirect{}
|
|
|
|
_ Render = Data{}
|
|
|
|
_ Render = HTML{}
|
|
|
|
_ HTMLRender = HTMLDebug{}
|
|
|
|
_ HTMLRender = HTMLProduction{}
|
2016-04-14 21:47:49 +00:00
|
|
|
_ Render = YAML{}
|
2017-02-23 14:08:37 +00:00
|
|
|
_ Render = MsgPack{}
|
2018-05-12 03:00:42 +00:00
|
|
|
_ Render = Reader{}
|
2018-08-06 15:08:01 +00:00
|
|
|
_ Render = AsciiJSON{}
|
2018-08-19 02:45:56 +00:00
|
|
|
_ Render = ProtoBuf{}
|
2014-07-15 15:41:56 +00:00
|
|
|
)
|
2015-06-13 02:29:10 +00:00
|
|
|
|
|
|
|
func writeContentType(w http.ResponseWriter, value []string) {
|
|
|
|
header := w.Header()
|
|
|
|
if val := header["Content-Type"]; len(val) == 0 {
|
|
|
|
header["Content-Type"] = value
|
|
|
|
}
|
|
|
|
}
|