1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-03 22:59:09 +02:00

Dropped support for func(http.Handler) http.Handler middleware

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-04-19 16:00:23 -07:00
parent 54824fc22f
commit 3eeea660fa
10 changed files with 52 additions and 156 deletions

View File

@@ -1,35 +0,0 @@
package middleware
import (
"log"
"time"
"github.com/labstack/echo"
"github.com/labstack/gommon/color"
)
func Logger(h echo.HandlerFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
start := time.Now()
if err := h(c); err != nil {
return err
}
end := time.Now()
col := color.Green
m := c.Request.Method
p := c.Request.URL.Path
n := c.Response.Status()
switch {
case n >= 500:
col = color.Red
case n >= 400:
col = color.Yellow
case n >= 300:
col = color.Cyan
}
log.Printf("%s %s %s %s", m, p, col(n), end.Sub(start))
return nil
}
}