mirror of
				https://github.com/traefik/traefik.git
				synced 2025-11-04 10:21:15 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			610 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			610 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package middlewares
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"log"
 | 
						|
	"net/http"
 | 
						|
 | 
						|
	"github.com/containous/mux"
 | 
						|
)
 | 
						|
 | 
						|
// Routes holds the gorilla mux routes (for the API & co).
 | 
						|
type Routes struct {
 | 
						|
	router *mux.Router
 | 
						|
}
 | 
						|
 | 
						|
// NewRoutes return a Routes based on the given 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) {
 | 
						|
		json, _ := json.Marshal(routeMatch.Handler)
 | 
						|
		log.Println("Request match route ", json)
 | 
						|
	}
 | 
						|
	next(rw, r)
 | 
						|
}
 |