2014-08-29 21:49:50 +04: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 19:41:56 +04:00
|
|
|
package render
|
|
|
|
|
2015-05-07 13:44:52 +03:00
|
|
|
import "net/http"
|
2015-03-08 19:50:58 +03:00
|
|
|
|
2015-05-07 13:44:52 +03:00
|
|
|
type Render interface {
|
|
|
|
Render(http.ResponseWriter, int, ...interface{}) error
|
|
|
|
}
|
2014-07-15 19:41:56 +04:00
|
|
|
|
|
|
|
var (
|
2015-05-07 13:44:52 +03:00
|
|
|
JSON Render = jsonRender{}
|
|
|
|
IndentedJSON Render = indentedJSON{}
|
|
|
|
XML Render = xmlRender{}
|
|
|
|
HTMLPlain Render = htmlPlainRender{}
|
|
|
|
Plain Render = plainTextRender{}
|
|
|
|
Redirect Render = redirectRender{}
|
|
|
|
Data Render = dataRender{}
|
|
|
|
_ Render = HTMLRender{}
|
|
|
|
_ Render = &HTMLDebugRender{}
|
2014-07-15 19:41:56 +04:00
|
|
|
)
|
|
|
|
|
2015-05-11 02:02:17 +03:00
|
|
|
func writeHeader(w http.ResponseWriter, code int, contentType string) {
|
2015-03-31 18:36:13 +03:00
|
|
|
w.Header().Set("Content-Type", contentType)
|
|
|
|
w.WriteHeader(code)
|
2014-09-17 07:33:13 +04:00
|
|
|
}
|