GetVarNames returns the names of all variables added by regexp matchers These can be used to know which route variables should be passed into r.URL()
()
| 731 | // GetVarNames returns the names of all variables added by regexp matchers |
| 732 | // These can be used to know which route variables should be passed into r.URL() |
| 733 | func (r *Route) GetVarNames() ([]string, error) { |
| 734 | if r.err != nil { |
| 735 | return nil, r.err |
| 736 | } |
| 737 | var varNames []string |
| 738 | if r.regexp.host != nil { |
| 739 | varNames = append(varNames, r.regexp.host.varsN...) |
| 740 | } |
| 741 | if r.regexp.path != nil { |
| 742 | varNames = append(varNames, r.regexp.path.varsN...) |
| 743 | } |
| 744 | for _, regx := range r.regexp.queries { |
| 745 | varNames = append(varNames, regx.varsN...) |
| 746 | } |
| 747 | return varNames, nil |
| 748 | } |
| 749 | |
| 750 | // prepareVars converts the route variable pairs into a map. If the route has a |
| 751 | // BuildVarsFunc, it is invoked. |
no outgoing calls