From 8043fff2a3e0710eba5efb7bed38bef79ed4fb45 Mon Sep 17 00:00:00 2001 From: Igor Dolzhikov Date: Sat, 31 Jan 2015 02:50:26 +0700 Subject: [PATCH 1/3] logger user function --- router.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/router.go b/router.go index bf43e1f..2a04972 100644 --- a/router.go +++ b/router.go @@ -92,8 +92,8 @@ type Router struct { // http status code http.StatusInternalServerError (500) PanicHandler Handle - // Logger activates logging for each requests - Logger bool + // Logger activates logging user function for each requests + Logger Handle } // Handle type is aliased to type of handler function. @@ -182,8 +182,8 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { } } }() - if r.Logger { - log.Println(req.RemoteAddr, req.Method, req.URL.Path) + if r.Logger != nil { + r.Logger(c) } if _, ok := r.handlers[req.Method]; ok { if handle, params, ok := r.handlers[req.Method].get(req.URL.Path); ok { From c41c455a434e85fea90b1cc26db75ce3fd7e3ba7 Mon Sep 17 00:00:00 2001 From: Igor Dolzhikov Date: Sat, 31 Jan 2015 03:14:10 +0700 Subject: [PATCH 2/3] add logger user function control params --- router.go | 1 + 1 file changed, 1 insertion(+) diff --git a/router.go b/router.go index 2a04972..6e327d2 100644 --- a/router.go +++ b/router.go @@ -183,6 +183,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { } }() if r.Logger != nil { + c := &Control{Request: req, Writer: w} r.Logger(c) } if _, ok := r.handlers[req.Method]; ok { From bbe4397f0bb1c7de7373bde9812a063271625b96 Mon Sep 17 00:00:00 2001 From: Igor Dolzhikov Date: Sat, 31 Jan 2015 03:19:50 +0700 Subject: [PATCH 3/3] Bumped version number to 0.2.8 --- router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router.go b/router.go index 6e327d2..a6cd9ad 100644 --- a/router.go +++ b/router.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. /* -Package router 0.2.7 provides fast HTTP request router. +Package router 0.2.8 provides fast HTTP request router. The router matches incoming requests by the request method and the path. If a handle is registered for this path and method, the router delegates the