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