Refactor routing and middleware architecture
This commit is contained in:
parent
08d41b0348
commit
fb97ba20c0
5 changed files with 62 additions and 51 deletions
16
logging/logger.go
Normal file
16
logging/logger.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Middleware(in http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
fmt.Println(r.Method, r.URL.String())
|
||||
in.ServeHTTP(w, r)
|
||||
fmt.Println(r.Method, "finished in", time.Since(start))
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue