github.com/corylanou/buffalo@v0.8.0/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].Method + a[i].Path
    33  	y := a[j].Method + a[j].Path
    34  	return x < y
    35  }