Skip to content

Instantly share code, notes, and snippets.

@wKoza
Last active April 12, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wKoza/de94eda0bf405fc49bbdcd849072e606 to your computer and use it in GitHub Desktop.
Save wKoza/de94eda0bf405fc49bbdcd849072e606 to your computer and use it in GitHub Desktop.
export const HTTP_INTERCEPTORS_1 = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS_1');
export const HTTP_INTERCEPTORS_2 = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS_2');
@Injectable()
export class Http1Service extends HttpClient {
constructor(backend: HttpBackend, private injector: Injector) {
super(new MyHandlerService(backend, injector, HTTP_INTERCEPTORS_1));
}
}
@Injectable()
export class Http2Service extends HttpClient {
constructor(backend: HttpBackend, private injector: Injector) {
super(new MyHandlerService(backend, injector, HTTP_INTERCEPTORS_2));
}
}
@NgModule({
providers: [
Int1Interceptor, Int2Interceptor, Int3Interceptor,
{provide: HTTP_INTERCEPTORS_1, useClass: Int1Interceptor, multi: true},
{provide: HTTP_INTERCEPTORS_2, useClass: Int2Interceptor, multi: true},
{provide: HTTP_INTERCEPTORS_2, useClass: Int3Interceptor, multi: true},
Http1Service, Http2Service,
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment