From 8f31fbc502f893af398fbba1a5b51bb95399b8fc Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Mon, 23 Mar 2015 04:42:05 +0100 Subject: [PATCH] Refactors render.go --- render/render.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/render/render.go b/render/render.go index bc7bceb8..09f13f50 100644 --- a/render/render.go +++ b/render/render.go @@ -17,28 +17,21 @@ type ( Render(http.ResponseWriter, int, ...interface{}) error } - // JSON binding jsonRender struct{} - // XML binding xmlRender struct{} - // Plain text - plainRender struct{} + plainTextRender struct{} - // HTML Plain text htmlPlainRender struct{} - // Redirects redirectRender struct{} - // Redirects htmlDebugRender struct { files []string globs []string } - // form binding HTMLRender struct { Template *template.Template } @@ -47,8 +40,8 @@ type ( var ( JSON = jsonRender{} XML = xmlRender{} - Plain = plainRender{} HTMLPlain = htmlPlainRender{} + Plain = plainTextRender{} Redirect = redirectRender{} HTMLDebug = &htmlDebugRender{} ) @@ -76,17 +69,16 @@ func (_ xmlRender) Render(w http.ResponseWriter, code int, data ...interface{}) return encoder.Encode(data[0]) } -func (_ plainRender) Render(w http.ResponseWriter, code int, data ...interface{}) error { +func (_ plainTextRender) Render(w http.ResponseWriter, code int, data ...interface{}) (err error) { writeHeader(w, code, "text/plain") format := data[0].(string) args := data[1].([]interface{}) - var err error if len(args) > 0 { _, err = w.Write([]byte(fmt.Sprintf(format, args...))) } else { _, err = w.Write([]byte(format)) } - return err + return } func (_ htmlPlainRender) Render(w http.ResponseWriter, code int, data ...interface{}) error {