我的问题与@ angular / http的Http模块的覆盖有关。我正在使用下一个代码拦截每个Http请求:
export let fakeBackendProvider = {
// intercepts every single Http call
provide: Http,
useFactory: (backend: MockBackend, options: BaseRequestOptions) => {
backend.connections.subscribe((connection) => {
// here I treat requests for their urls
if(connection.endsWith('/example/') {
// ...
}
// here I'd like to CONTINUE the normal execution as it is,
// as if THIS call had never entered in "useFactory" peace of code
if(connection.endsWith('/example.noprovider/') {
// GO ON
}
})
return new Http(backend, options)
},
deps: [MockBackend, BaseRequestOptions]
}
我需要什么
问题
我的拦截器(上面的代码)总是站在HTTP调用之前,但是根据HTTP请求的URL,我需要使用那个拦截器。
我在寻找什么
“分离”例程的一些功能,如:
INSIDE THE INTERCEPTOR
if(url === 'useinterceptor) {
// USE INTERCEPTOR
}
if(url === 'notuseinterceptor') {
// USE HTTP GET OPERATION AS IT IS
}