Advertisement
Savvoy

note

Nov 26th, 2020
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.58 KB | None | 0 0
  1. func (app *App) setRouters() {
  2.     for _, route := range routes.DefinedRoutes {
  3.         var handler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
  4.             start := time.Now()
  5.             log.Printf(
  6.                 "%s\t%s\t%s\t%s",
  7.                 r.Method,
  8.                 r.RequestURI,
  9.                 route.Name,
  10.                 time.Since(start),
  11.             )
  12.            
  13.             route.RouteHandle(app.DB , w, r)
  14.         }
  15.        
  16.         app.Router.HandleFunc(route.Pattern, handler).
  17.             Name(route.Name).
  18.             Methods(route.Method)
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement