Last active
November 6, 2019 00:25
-
-
Save johan-lejdung/b9514c96e5460fbe3bd0dc3ec94b72da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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