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

Function copyRouteConf

mux.go:100–120  ·  view source on GitHub ↗

returns an effective deep copy of `routeConf`

(r routeConf)

Source from the content-addressed store, hash-verified

98
99// returns an effective deep copy of `routeConf`
100func copyRouteConf(r routeConf) routeConf {
101 c := r
102
103 if r.regexp.path != nil {
104 c.regexp.path = copyRouteRegexp(r.regexp.path)
105 }
106
107 if r.regexp.host != nil {
108 c.regexp.host = copyRouteRegexp(r.regexp.host)
109 }
110
111 c.regexp.queries = make([]*routeRegexp, 0, len(r.regexp.queries))
112 for _, q := range r.regexp.queries {
113 c.regexp.queries = append(c.regexp.queries, copyRouteRegexp(q))
114 }
115
116 c.matchers = make([]matcher, len(r.matchers))
117 copy(c.matchers, r.matchers)
118
119 return c
120}
121
122func copyRouteRegexp(r *routeRegexp) *routeRegexp {
123 c := *r

Callers 3

NewRouteMethod · 0.85
Test_copyRouteConfFunction · 0.85
SubrouterMethod · 0.85

Calls 1

copyRouteRegexpFunction · 0.85

Tested by 1

Test_copyRouteConfFunction · 0.68