1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-01 22:51:17 +02:00

Flexible handler and middleware

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-03-25 08:50:24 -07:00
parent 99124cda0a
commit e49e74aeac
8 changed files with 138 additions and 86 deletions

View File

@@ -8,10 +8,10 @@ import (
"github.com/labstack/gommon/color"
)
func Logger() bolt.HandlerFunc {
return func(c *bolt.Context) {
func Logger(h bolt.HandlerFunc) bolt.HandlerFunc {
return bolt.HandlerFunc(func(c *bolt.Context) {
start := time.Now()
c.Next()
h(c)
end := time.Now()
col := color.Green
m := c.Request.Method
@@ -28,5 +28,5 @@ func Logger() bolt.HandlerFunc {
}
log.Printf("%s %s %s %s", m, p, col(s), end.Sub(start))
}
})
}