MCPcopy Create free account
hub / github.com/goadesign/goa / mergeInterceptors

Function mergeInterceptors

expr/method.go:289–309  ·  view source on GitHub ↗

mergeInterceptors merges interceptors from different levels (method, service, API) while avoiding duplicates. The order of precedence is: method > service > API.

(methodLevel, serviceLevel, apiLevel []*InterceptorExpr)

Source from the content-addressed store, hash-verified

287// mergeInterceptors merges interceptors from different levels (method, service, API)
288// while avoiding duplicates. The order of precedence is: method > service > API.
289func mergeInterceptors(methodLevel, serviceLevel, apiLevel []*InterceptorExpr) []*InterceptorExpr {
290 existing := make(map[string]struct{})
291 result := make([]*InterceptorExpr, 0, len(methodLevel)+len(serviceLevel)+len(apiLevel))
292
293 for _, i := range methodLevel {
294 existing[i.Name] = struct{}{}
295 result = append(result, i)
296 }
297 for _, i := range serviceLevel {
298 if _, ok := existing[i.Name]; !ok {
299 result = append(result, i)
300 existing[i.Name] = struct{}{}
301 }
302 }
303 for _, i := range apiLevel {
304 if _, ok := existing[i.Name]; !ok {
305 result = append(result, i)
306 }
307 }
308 return result
309}
310
311// hasTag is a helper function that traverses the given attribute and all its
312// bases recursively looking for an attribute with the given tag meta. This

Callers 1

validateInterceptorsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected