MCPcopy Create free account
hub / github.com/angular/angular / legacyInterceptorFnFactory

Function legacyInterceptorFnFactory

packages/common/http/src/interceptor.ts:220–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218 * class-based interceptors and runs the request through it.
219 */
220export function legacyInterceptorFnFactory(): HttpInterceptorFn {
221 let chain: ChainedInterceptorFn<any> | null = null;
222
223 return (req, handler) => {
224 if (chain === null) {
225 const interceptors = inject(HTTP_INTERCEPTORS, {optional: true}) ?? [];
226 // Note: interceptors are wrapped right-to-left so that final execution order is
227 // left-to-right. That is, if `interceptors` is the array `[a, b, c]`, we want to
228 // produce a chain that is conceptually `c(b(a(end)))`, which we build from the inside
229 // out.
230 chain = interceptors.reduceRight(
231 adaptLegacyInterceptorToChain,
232 interceptorChainEndFn as ChainedInterceptorFn<any>,
233 );
234 }
235
236 return chain(req, handler);
237 };
238}

Callers

nothing calls this directly

Calls 2

injectFunction · 0.90
chainFunction · 0.50

Tested by

no test coverage detected