Skip to content

Instantly share code, notes, and snippets.

@johan-lejdung
Last active November 6, 2019 00:25
Show Gist options
  • Save johan-lejdung/b9514c96e5460fbe3bd0dc3ec94b72da to your computer and use it in GitHub Desktop.
Save johan-lejdung/b9514c96e5460fbe3bd0dc3ec94b72da to your computer and use it in GitHub Desktop.
package mw
import (
"fmt"
"net/http"
"time"
)
type Logger struct{}
func (*Logger) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
fmt.Println("The logger middleware is executing!")
t := time.Now()
next.ServeHTTP(w, r)
fmt.Printf("Execution time: %s \n", time.Now().Sub(t).String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment