angular-styleguide icon indicating copy to clipboard operation
angular-styleguide copied to clipboard

Where is the best location to place HttpInterceptors?

Open cknightdevelopment opened this issue 9 years ago • 2 comments

I was wondering where the best location might be to place classes that inherit from HttpInterceptor? I am have interceptors for logging, caching, authorization, etc. Would these be appropriate in CoreModule? Same question for route guards. Thanks!

cknightdevelopment avatar Aug 31 '17 15:08 cknightdevelopment

Both HTTP interceptors and route guards belong in the CoreModule. Singleton services that are instantiated once and used across the entire app. Interceptors and guards are: -Application-wide -Singleton by design -Infrastructure-level (not feature-specific) -Registered once (or should be) That makes them a perfect fit for CoreModule.

kartik1211 avatar Jan 07 '26 03:01 kartik1211

Great question! The Angular 2+ style guide in this repo defers to the official Angular style guide maintained by the Angular team at https://angular.dev/style-guide — that's the best place for current Angular (2+) and TypeScript conventions. Closing this here, but the official guide should cover this well. 🙏

johnpapa avatar Apr 30 '26 18:04 johnpapa