gund / ng-http-interceptor

Http Interceptor library for Angular
MIT License
104 stars 16 forks source link

Add support for new HttpClient #170

Open gund opened 7 years ago

gund commented 7 years ago

Angular 5 introduced new @angular/common/http library so we need to support it in some way.

  1. 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
  2. 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.

kenisteward commented 6 years ago

@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

gund commented 6 years ago

@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 =)

kenisteward commented 6 years ago
  1. 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?

  2. 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 notifications@github.com 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 .

gund commented 6 years ago
  1. 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.

  2. 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 =)

raykin commented 6 years ago

How to get the httpClient works with interceptor? I'm stuck on it.