Merge route data into the existing configuration. This is typically used by adapters, such as the chiadapter to take information that the router already knows and add it to the specification.
(r Route)
| 158 | // to take information that the router already knows and add it |
| 159 | // to the specification. |
| 160 | func (api *API) Merge(r Route) { |
| 161 | toUpdate := api.Route(string(r.Method), string(r.Pattern)) |
| 162 | mergeMap(toUpdate.Params.Path, r.Params.Path) |
| 163 | mergeMap(toUpdate.Params.Query, r.Params.Query) |
| 164 | if toUpdate.Models.Request.Type == nil { |
| 165 | toUpdate.Models.Request = r.Models.Request |
| 166 | } |
| 167 | mergeMap(toUpdate.Models.Responses, r.Models.Responses) |
| 168 | } |
| 169 | |
| 170 | func mergeMap[TKey comparable, TValue any](into, from map[TKey]TValue) { |
| 171 | for kf, vf := range from { |