RemoveHandler deletes a handler from begin and done handlers based on its name or the handler pc function. Note that UseGlobal and DoneGlobal handlers cannot be removed through this method as they were registered to the routes already. As an exception, if one of the arguments is a pointer to an int
(namesOrHandlers ...interface{})
| 1402 | // |
| 1403 | // Should be called before children routes regitration. |
| 1404 | func (api *APIBuilder) RemoveHandler(namesOrHandlers ...interface{}) Party { |
| 1405 | var counter *int |
| 1406 | |
| 1407 | for _, nameOrHandler := range namesOrHandlers { |
| 1408 | handlerName := "" |
| 1409 | switch h := nameOrHandler.(type) { |
| 1410 | case string: |
| 1411 | handlerName = h |
| 1412 | case context.Handler: //, func(*context.Context): |
| 1413 | handlerName = context.HandlerName(h) |
| 1414 | case *int: |
| 1415 | counter = h |
| 1416 | default: |
| 1417 | panic(fmt.Sprintf("remove handler: unexpected type of %T", h)) |
| 1418 | } |
| 1419 | |
| 1420 | api.middleware = removeHandler(handlerName, api.middleware, counter) |
| 1421 | api.doneHandlers = removeHandler(handlerName, api.doneHandlers, counter) |
| 1422 | } |
| 1423 | |
| 1424 | return api |
| 1425 | } |
| 1426 | |
| 1427 | // Reset removes all the begin and done handlers that may derived from the parent party via `Use` & `Done`, |
| 1428 | // and the execution rules. |
nothing calls this directly
no test coverage detected