From d6771dc4a5675b791e060d6fffe4255f86a0ecd3 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Sat, 9 May 2015 03:35:31 +0200 Subject: [PATCH] Cosmetic changes --- context.go | 9 +++------ logger.go | 22 +++++++++++----------- render/render_test.go | 3 +++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/context.go b/context.go index 44b82e7..7407574 100644 --- a/context.go +++ b/context.go @@ -184,25 +184,22 @@ func (c *Context) ParamValue(key string) (va string) { func (c *Context) DefaultPostFormValue(key, defaultValue string) string { if va, ok := c.postFormValue(key); ok { return va - } else { - return defaultValue } + return defaultValue } func (c *Context) DefaultFormValue(key, defaultValue string) string { if va, ok := c.formValue(key); ok { return va - } else { - return defaultValue } + return defaultValue } func (c *Context) DefaultParamValue(key, defaultValue string) string { if va, ok := c.paramValue(key); ok { return va - } else { - return defaultValue } + return defaultValue } func (c *Context) paramValue(key string) (string, bool) { diff --git a/logger.go b/logger.go index 87304dd..5eb9023 100644 --- a/logger.go +++ b/logger.go @@ -75,11 +75,11 @@ func LoggerWithFile(out io.Writer) HandlerFunc { func colorForStatus(code int) string { switch { - case code >= 200 && code <= 299: + case code >= 200 && code < 300: return green - case code >= 300 && code <= 399: + case code >= 300 && code < 400: return white - case code >= 400 && code <= 499: + case code >= 400 && code < 500: return yellow default: return red @@ -87,20 +87,20 @@ func colorForStatus(code int) string { } func colorForMethod(method string) string { - switch { - case method == "GET": + switch method { + case "GET": return blue - case method == "POST": + case "POST": return cyan - case method == "PUT": + case "PUT": return yellow - case method == "DELETE": + case "DELETE": return red - case method == "PATCH": + case "PATCH": return green - case method == "HEAD": + case "HEAD": return magenta - case method == "OPTIONS": + case "OPTIONS": return white default: return reset diff --git a/render/render_test.go b/render/render_test.go index 6f27f04..0ffcf4d 100644 --- a/render/render_test.go +++ b/render/render_test.go @@ -13,6 +13,9 @@ import ( "github.com/stretchr/testify/assert" ) +// TODO unit tests +// test errors + func TestRenderJSON(t *testing.T) { w := httptest.NewRecorder() w2 := httptest.NewRecorder()