MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / _setupHandlerIfNeeded

Method _setupHandlerIfNeeded

packages/rest/src/rest.server.ts:398–418  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 2

httpHandlerMethod · 0.95
startMethod · 0.95

Calls 4

_createHttpHandlerMethod · 0.95
filterByKeyFunction · 0.85
filterByTagFunction · 0.85
subscribeMethod · 0.45

Tested by

no test coverage detected