UpsertHandlers like `JoinHandlers` but it does NOT copies the handlers entries and it does remove duplicates.
(h1 Handlers, h2 Handlers)
| 371 | // UpsertHandlers like `JoinHandlers` but it does |
| 372 | // NOT copies the handlers entries and it does remove duplicates. |
| 373 | func UpsertHandlers(h1 Handlers, h2 Handlers) Handlers { |
| 374 | reg: |
| 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. |
| 392 | func CopyHandlers(handlers Handlers) Handlers { |
no test coverage detected
searching dependent graphs…