1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00

fix middleware code

This commit is contained in:
Xargin 2018-03-25 10:52:30 +08:00
parent 12ee66dfdf
commit 11ec1cd5c2

View File

@ -107,7 +107,7 @@ func hello(wr http.ResponseWriter, r *http.Request) {
}
func timeMiddleware(next http.Handler) http.Handler {
return func(wr http.ResponseWriter, r *http.Request) {
return http.HandlerFunc(func(wr http.ResponseWriter, r *http.Request) {
timeStart := time.Now()
// next handler
@ -115,7 +115,7 @@ func timeMiddleware(next http.Handler) http.Handler {
timeElapsed := time.Since(timeStart)
logger.Println(timeElapsed)
}
})
}
func main() {