github.com/jasonish/buffalo@v0.8.2-0.20170413145823-bacbdd415f1b/route.go (about) 1 package buffalo 2 3 import "github.com/gorilla/mux" 4 5 // Routes returns a list of all of the routes defined 6 // in this application. 7 func (a *App) Routes() RouteList { 8 if a.root != nil { 9 return a.root.routes 10 } 11 return a.routes 12 } 13 14 // RouteInfo provides information about the underlying route that 15 // was built. 16 type RouteInfo struct { 17 Method string `json:"method"` 18 Path string `json:"path"` 19 HandlerName string `json:"handler"` 20 MuxRoute *mux.Route `json:"-"` 21 Handler Handler `json:"-"` 22 } 23 24 // RouteList contains a mapping of the routes defined 25 // in the application. This listing contains, Method, Path, 26 // and the name of the Handler defined to process that route. 27 type RouteList []RouteInfo 28 29 func (a RouteList) Len() int { return len(a) } 30 func (a RouteList) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 31 func (a RouteList) Less(i, j int) bool { 32 x := a[i].Path // + a[i].Method 33 y := a[j].Path // + a[j].Method 34 return x < y 35 }