You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
393 B

  1. package main
  2. import (
  3. "net/http"
  4. "github.com/gorilla/mux"
  5. )
  6. func NewRouter() *mux.Router {
  7. router := mux.NewRouter().StrictSlash(true)
  8. for _, route := range routes {
  9. var handler http.Handler
  10. handler = route.HandlerFunc
  11. handler = Logger(handler, route.Name)
  12. router.
  13. Methods(route.Method).
  14. Path(route.Pattern).
  15. Name(route.Name).
  16. Handler(handler)
  17. }
  18. return router
  19. }