Check if a http interceptor is provided · Issue #57409 · angular/angular · GitHub
Skip to content

Check if a http interceptor is provided #57409

Description

@MurhafSousli

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

In my library, I expose a HTTP interceptor. since it is a deliberate design of the new API to require the user to add the interceptor manually in withInterceptors function (#51303,). there is a need to throw an exception or notify the user that he forgot to add the specific interceptor.

Related SO https://stackoverflow.com/questions/78869196/how-to-check-if-an-interceptor-is-provided-in-withinterceptors-fucntion?noredirect=1#comment139055699_78869196

How can this be accomplished?

Proposed solution

An injection token that can be injected in a singleton service to check for the added Http interceptors. and can throw an error accordingly.

Alternatives considered

Many libraries may include interceptors, and the new API design prevents authors from automatically adding the needed interceptors. there must be a way to notify the user for not adding an interceptor when he uses the library.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: common/httpIssues related to HTTP and HTTP ClientfeatureLabel used to distinguish feature request from other issuesopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions