diff --git a/echo.go b/echo.go index cbdd473d..8a73b9fb 100644 --- a/echo.go +++ b/echo.go @@ -563,7 +563,7 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Middleware h := func(c Context) error { method := r.Method - rpath := r.URL.RawPath // raw path + rpath := r.URL.RawPath // Raw path if rpath == "" { rpath = r.URL.Path } diff --git a/middleware/compress_test.go b/middleware/compress_test.go index ece13bd6..d9661cd9 100644 --- a/middleware/compress_test.go +++ b/middleware/compress_test.go @@ -93,7 +93,7 @@ func TestGzipWithStatic(t *testing.T) { defer r.Close() want, err := ioutil.ReadFile("../_fixture/images/walle.png") if assert.NoError(t, err) { - var buf bytes.Buffer + buf := new(bytes.Buffer) buf.ReadFrom(r) assert.Equal(t, want, buf.Bytes()) } diff --git a/middleware/csrf.go b/middleware/csrf.go index dbf1cc62..5d1f4671 100644 --- a/middleware/csrf.go +++ b/middleware/csrf.go @@ -124,8 +124,7 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc { req := c.Request() k, err := c.Cookie(config.CookieName) - - var token string + token := "" // Generate token if err != nil { @@ -144,7 +143,7 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc { return echo.NewHTTPError(http.StatusBadRequest, err.Error()) } if !validateCSRFToken(token, clientToken) { - return echo.NewHTTPError(http.StatusForbidden, "Invalid csrf token") + return echo.NewHTTPError(http.StatusForbidden, "invalid csrf token") } } diff --git a/middleware/jwt.go b/middleware/jwt.go index 722cade9..f63ec9e3 100644 --- a/middleware/jwt.go +++ b/middleware/jwt.go @@ -58,8 +58,8 @@ const ( // Errors var ( - ErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, "Missing or malformed jwt") - ErrJWTInvalid = echo.NewHTTPError(http.StatusUnauthorized, "Invalid or expired jwt") + ErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, "missing or malformed jwt") + ErrJWTInvalid = echo.NewHTTPError(http.StatusUnauthorized, "invalid or expired jwt") ) var ( diff --git a/router.go b/router.go index ce81a58f..cd91dc80 100644 --- a/router.go +++ b/router.go @@ -59,8 +59,8 @@ func (r *Router) Add(method, path string, h HandlerFunc) { if path[0] != '/' { path = "/" + path } - ppath := path // Pristine path - var pnames []string // Param names + pnames := []string{} // Param names + ppath := path // Pristine path for i, l := 0, len(path); i < l; i++ { if path[i] == ':' {