MCPcopy Create free account
hub / github.com/kataras/iris / UpsertHandlers

Function UpsertHandlers

context/handler.go:373–389  ·  view source on GitHub ↗

UpsertHandlers like `JoinHandlers` but it does NOT copies the handlers entries and it does remove duplicates.

(h1 Handlers, h2 Handlers)

Source from the content-addressed store, hash-verified

371// UpsertHandlers like `JoinHandlers` but it does
372// NOT copies the handlers entries and it does remove duplicates.
373func UpsertHandlers(h1 Handlers, h2 Handlers) Handlers {
374reg:
375 for _, handler := range h2 {
376 name := HandlerName(handler)
377 for i, registeredHandler := range h1 {
378 registeredName := HandlerName(registeredHandler)
379 if name == registeredName {
380 h1[i] = handler // replace this handler with the new one.
381 continue reg // break and continue to the next handler.
382 }
383 }
384
385 h1 = append(h1, handler) // or just insert it.
386 }
387
388 return h1
389}
390
391// CopyHandlers returns a copy of "handlers" Handlers slice.
392func CopyHandlers(handlers Handlers) Handlers {

Callers 4

UseRouterMethod · 0.92
UseErrorMethod · 0.92
UseOnceMethod · 0.92
UseOnceMethod · 0.92

Calls 1

HandlerNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…