Reto: Incluir tiempo de ejecución total de los middleware
Hola profe @alexyslozada66750
Esta es mi propuesta para agregar un timetrack para verificar cuando tiempo tomo la ejecución, espero cumpla con el reto propuesto, un saludo profe, excelente curso
type HandlerSign func(w http.ResponseWriter, r *http.Request)
func Log(f HandlerSign) HandlerSign {
return func(w http.ResponseWriter, r *http.Request) {
defer TimeTrack(time.Now(), r.URL.Path)
log.Printf("request %q, method %q", r.URL.Path, r.Method)
f(w, r)
}
}
func TimeTrack(start time.Time, name string) {
elapsed := time.Since(start)
log.Printf("%q execution time: %s", name, elapsed)
}
