MCPcopy
hub / github.com/gorilla/mux / GetVarNames

Method GetVarNames

route.go:733–748  ·  view source on GitHub ↗

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()

()

Source from the content-addressed store, hash-verified

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()
733func (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.

Callers 2

TestGetVarNamesFunction · 0.80
ExampleRoute_GetVarNamesFunction · 0.80

Calls

no outgoing calls

Tested by 2

TestGetVarNamesFunction · 0.64
ExampleRoute_GetVarNamesFunction · 0.64