UseRouter upserts one or more handlers that will be fired right before the main router's request handler. Use this method to register handlers, that can ran independently of the incoming request's values, that they will be executed ALWAYS against ALL children incoming requests. Example of use-case:
(handlers ...context.Handler)
| 1253 | // The context SHOULD call its `Next` method in order to proceed to |
| 1254 | // the next handler in the chain or the main request handler one. |
| 1255 | func (api *APIBuilder) UseRouter(handlers ...context.Handler) { |
| 1256 | if len(handlers) == 0 || handlers[0] == nil { |
| 1257 | return |
| 1258 | } |
| 1259 | |
| 1260 | beginHandlers := context.Handlers(handlers) |
| 1261 | // respect any execution rules (begin). |
| 1262 | api.handlerExecutionRules.Begin.apply(&beginHandlers) |
| 1263 | beginHandlers = context.JoinHandlers(api.routerFilterHandlers, beginHandlers) |
| 1264 | |
| 1265 | if f := api.routerFilters[api]; f != nil && len(f.Handlers) > 0 { // exists. |
| 1266 | beginHandlers = context.UpsertHandlers(f.Handlers, beginHandlers) // remove dupls. |
| 1267 | } |
| 1268 | |
| 1269 | // we are not using the parent field here, |
| 1270 | // we need to have control over those values in order to be able to `Reset`. |
| 1271 | api.routerFilterHandlers = beginHandlers |
| 1272 | |
| 1273 | subdomain, path := splitSubdomainAndPath(api.relativePath) |
| 1274 | api.routerFilters[api] = &Filter{ |
| 1275 | Matcher: api, |
| 1276 | Subdomain: subdomain, |
| 1277 | Path: path, |
| 1278 | Handlers: beginHandlers, |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | // GetDefaultErrorMiddleware returns the application's error pre handlers |
| 1283 | // registered through `UseError` for the default error handlers. |
nothing calls this directly
no test coverage detected