(next http.HandlerFunc)
| 99 | } |
| 100 | |
| 101 | func logMiddleware(next http.HandlerFunc) http.HandlerFunc { |
| 102 | return func(w http.ResponseWriter, r *http.Request) { |
| 103 | if *logRequests { |
| 104 | start := time.Now() |
| 105 | next(w, r) |
| 106 | log.Printf("%s %s %s %v", r.Method, r.URL.Path, r.RemoteAddr, time.Since(start)) |
| 107 | } else { |
| 108 | next(w, r) |
| 109 | } |
| 110 | } |
| 111 | } |