Files
7days-golang/day5-middleware/gee/logger.go
T
2019-08-17 01:47:14 +08:00

18 lines
275 B
Go

package gee
import (
"log"
"time"
)
func Logger() HandlerFunc {
return func(c *Context) {
// Start timer
t := time.Now()
// Process request
c.Next()
// Calculate resolution time
log.Printf("[%d] %s in %v", c.StatusCode, c.Req.RequestURI, time.Since(t))
}
}