()
| 396 | } |
| 397 | |
| 398 | protected _setupHandlerIfNeeded() { |
| 399 | if (this._httpHandler) return; |
| 400 | |
| 401 | // Watch for binding events |
| 402 | // See https://github.com/loopbackio/loopback-next/issues/433 |
| 403 | const routesObserver: ContextObserver = { |
| 404 | filter: binding => |
| 405 | filterByKey(RestBindings.API_SPEC.key)(binding) || |
| 406 | (filterByKey(/^(controllers|routes)\..+/)(binding) && |
| 407 | // Exclude controller routes to avoid circular events |
| 408 | !filterByTag(RestTags.CONTROLLER_ROUTE)(binding)), |
| 409 | observe: () => { |
| 410 | // Rebuild the HttpHandler instance whenever a controller/route was |
| 411 | // added/deleted. |
| 412 | this._createHttpHandler(); |
| 413 | }, |
| 414 | }; |
| 415 | this._routesEventSubscription = this.subscribe(routesObserver); |
| 416 | |
| 417 | this._createHttpHandler(); |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Create an instance of HttpHandler and populates it with routes |
no test coverage detected