MiddlewareExists reports whether the given handler exists in the middleware chain.
(handlerNameOrFunc any)
| 1372 | |
| 1373 | // MiddlewareExists reports whether the given handler exists in the middleware chain. |
| 1374 | func (api *APIBuilder) MiddlewareExists(handlerNameOrFunc any) bool { |
| 1375 | if handlerNameOrFunc == nil { |
| 1376 | return false |
| 1377 | } |
| 1378 | |
| 1379 | var handlers context.Handlers |
| 1380 | |
| 1381 | if filter, ok := api.routerFilters[api]; ok { |
| 1382 | handlers = append(handlers, filter.Handlers...) |
| 1383 | } |
| 1384 | |
| 1385 | handlers = append(handlers, api.middleware...) |
| 1386 | handlers = append(handlers, api.doneHandlers...) |
| 1387 | handlers = append(handlers, api.beginGlobalHandlers...) |
| 1388 | handlers = append(handlers, api.doneGlobalHandlers...) |
| 1389 | |
| 1390 | return context.HandlerExists(handlers, handlerNameOrFunc) |
| 1391 | } |
| 1392 | |
| 1393 | // RemoveHandler deletes a handler from begin and done handlers |
| 1394 | // based on its name or the handler pc function. |
nothing calls this directly
no test coverage detected