fix(platform-server): avoid dependency cycle when using http interceptor (#24229)

Fixes #23023.

When a HTTP Interceptor injects HttpClient it causes a DI cycle. This fix is to use Injector to lazily inject HTTP_INTERCEPTORS while setting up the HttpHandler on the server so as to break the cycle.

PR Close #24229
This commit is contained in:
Vikram Subramanian
2018-05-31 10:35:51 -07:00
committed by Victor Berchet
parent 68a799e950
commit 60aa943e2d
4 changed files with 44 additions and 26 deletions

View File

@ -42,23 +42,6 @@ export class HttpInterceptingHandler implements HttpHandler {
}
}
/**
* Constructs an `HttpHandler` that applies a bunch of `HttpInterceptor`s
* to a request before passing it to the given `HttpBackend`.
*
* Meant to be used as a factory function within `HttpClientModule`.
*
*
*/
export function interceptingHandler(
backend: HttpBackend, interceptors: HttpInterceptor[] | null = []): HttpHandler {
if (!interceptors) {
return backend;
}
return interceptors.reduceRight(
(next, interceptor) => new HttpInterceptorHandler(next, interceptor), backend);
}
/**
* Factory function that determines where to store JSONP callbacks.
*