1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 15:19:42 +02:00

cosmetics

This commit is contained in:
Harvey Kandola 2017-07-21 18:21:34 +01:00
parent d888962082
commit 25b576f861
3 changed files with 24 additions and 19 deletions

View file

@ -43,6 +43,23 @@ type routeMap map[string]RouteFunc
var routes = make(routeMap)
type routeSortItem struct {
def routeDef
fun RouteFunc
ord int
}
type routeSorter []routeSortItem
func (s routeSorter) Len() int { return len(s) }
func (s routeSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s routeSorter) Less(i, j int) bool {
if s[i].def.Prefix == s[j].def.Prefix && s[i].def.Path == s[j].def.Path {
return len(s[i].def.Queries) > len(s[j].def.Queries)
}
return s[i].ord < s[j].ord
}
func routesKey(rt env.Runtime, prefix, path string, methods, queries []string) (string, error) {
rd := routeDef{
Prefix: prefix,
@ -79,23 +96,6 @@ func Remove(rt env.Runtime, prefix, path string, methods, queries []string) erro
return nil
}
type routeSortItem struct {
def routeDef
fun RouteFunc
ord int
}
type routeSorter []routeSortItem
func (s routeSorter) Len() int { return len(s) }
func (s routeSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s routeSorter) Less(i, j int) bool {
if s[i].def.Prefix == s[j].def.Prefix && s[i].def.Path == s[j].def.Path {
return len(s[i].def.Queries) > len(s[j].def.Queries)
}
return s[i].ord < s[j].ord
}
// BuildRoutes returns all matching routes for specified scope.
func BuildRoutes(rt env.Runtime, prefix string) *mux.Router {
var rs routeSorter