traefik/middlewares/routes.go

29 lines
507 B
Go
Raw Normal View History

2015-09-12 17:22:44 +00:00
/*
Copyright
*/
package middlewares
import (
"encoding/json"
"github.com/gorilla/mux"
2015-09-12 17:22:44 +00:00
"log"
"net/http"
)
type Routes struct {
router *mux.Router
}
func NewRoutes(router *mux.Router) *Routes {
return &Routes{router}
}
func (router *Routes) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
routeMatch := mux.RouteMatch{}
if router.router.Match(r, &routeMatch) {
2015-09-12 17:22:44 +00:00
json, _ := json.Marshal(routeMatch.Handler)
log.Println("Request match route ", json)
}
next(rw, r)
}