MCPcopy Create free account
hub / github.com/a-h/rest / Merge

Method Merge

api.go:160–168  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

158// to take information that the router already knows and add it
159// to the specification.
160func (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
170func mergeMap[TKey comparable, TValue any](into, from map[TKey]TValue) {
171 for kf, vf := range from {

Callers 1

MergeFunction · 0.80

Calls 2

RouteMethod · 0.95
mergeMapFunction · 0.85

Tested by

no test coverage detected