Created
April 25, 2020 14:41
-
-
Save Daniel1984/5b2aa966f5c91a81d63622819fe39b2e 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
// pkg/middleware/logging.go | |
package middleware | |
import ( | |
"net/http" | |
"github.com/boilerplate/pkg/logger" | |
"github.com/julienschmidt/httprouter" | |
) | |
func LogRequest(next httprouter.Handle) httprouter.Handle { | |
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { | |
logger.Info.Printf("%s - %s %s %s", r.RemoteAddr, r.Proto, r.Method, r.URL.RequestURI()) | |
next(w, r, p) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment