()
| 618 | } |
| 619 | |
| 620 | func (n *node) routes() []Route { |
| 621 | rts := []Route{} |
| 622 | |
| 623 | n.walk(func(eps endpoints, subroutes Routes) bool { |
| 624 | if eps[mSTUB] != nil && eps[mSTUB].handler != nil && subroutes == nil { |
| 625 | return false |
| 626 | } |
| 627 | |
| 628 | // Group methodHandlers by unique patterns |
| 629 | pats := make(map[string]endpoints) |
| 630 | |
| 631 | for mt, h := range eps { |
| 632 | if h.pattern == "" { |
| 633 | continue |
| 634 | } |
| 635 | p, ok := pats[h.pattern] |
| 636 | if !ok { |
| 637 | p = endpoints{} |
| 638 | pats[h.pattern] = p |
| 639 | } |
| 640 | p[mt] = h |
| 641 | } |
| 642 | |
| 643 | for p, mh := range pats { |
| 644 | hs := make(map[string]http.Handler) |
| 645 | if mh[mALL] != nil && mh[mALL].handler != nil { |
| 646 | hs["*"] = mh[mALL].handler |
| 647 | } |
| 648 | |
| 649 | for mt, h := range mh { |
| 650 | if h.handler == nil { |
| 651 | continue |
| 652 | } |
| 653 | if m, ok := reverseMethodMap[mt]; ok { |
| 654 | hs[m] = h.handler |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | rt := Route{subroutes, hs, p} |
| 659 | rts = append(rts, rt) |
| 660 | } |
| 661 | |
| 662 | return false |
| 663 | }) |
| 664 | |
| 665 | return rts |
| 666 | } |
| 667 | |
| 668 | func (n *node) walk(fn func(eps endpoints, subroutes Routes) bool) bool { |
| 669 | // Visit the leaf values if any |
no test coverage detected