ng-http-interceptor
ng-http-interceptor copied to clipboard
Add support for new HttpClient
Angular 5 introduced new @angular/common/http library so we need to support it in some way.
-
First approach:
- Deprecate current
HttpInterceptorModule - Create new module which will provide interception for the newer http module
- Make sure that you can use both modules at the same time so that you can intercept requests made from both angular http clients
- Deprecate current
-
Second approach:
- Give user ability to pass http client he want to use for interception and then library will use that and provide wrapped version of it for DI.
This will be nicer way but requires some investigation.
@gund Angular 4.3 and above HttpClient supports creating native angular interceptors. If you are using it, you should migrate away from using this library I think.
Docs https://angular.io/guide/http#advanced-usage
@kenisteward thanks, I know about native support.
But this library still offers at least one feature you will not get from there - changing interceptors at runtime.
I had specifically that requirement in one of my project, so it might be useful for others as well.
And anyway these interceptors are fully compatible with native ones, so you can use one or another or both at the same time =)
-
I was actually wondering if I have interceptors setup with httpmodule if requests on httpclient would be intercepted with this lib. I don't think it will right?
-
If you can't get runtime interceptor switches with the base interceptor I'm not sure if updating this to use the new base one will help you right? Unless it is updated to override it fully.
On Tue, Dec 19, 2017, 3:08 PM Alex Malkevich [email protected] wrote:
@kenisteward https://github.com/kenisteward thanks, I know about native support.
But this library still offers at least one feature you will not get from there - changing interceptors at runtime.
I had specifically that requirement in one of my project, so it might be useful for others as well.
And anyway these interceptors are fully compatible with native ones, so you can use one or another or both at the same time =)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gund/ng-http-interceptor/issues/170#issuecomment-352872024, or mute the thread https://github.com/notifications/unsubscribe-auth/AMPLtXTQqR1UDVMpyxC1pU-c087P0o_iks5tCBevgaJpZM4QXFZf .
-
That is the purpose of this issue, to add support for the new http client. And basically I already made it working, only need to make sure AOT will still work.
-
The reason for me to keep this library is that it is not bound specifically to any http client, it just proxies it without any particular requirements. So if it can manipulate interceptors at runtime with old client, it also will do with the new one. And again, I already tested it locally - it does work perfectly fine =)
How to get the httpClient works with interceptor? I'm stuck on it.