Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed: path interceptors for http module #194

Closed
emoralesb05 opened this issue Dec 15, 2016 · 1 comment
Closed

Proposed: path interceptors for http module #194

emoralesb05 opened this issue Dec 15, 2016 · 1 comment

Comments

@emoralesb05
Copy link
Contributor

emoralesb05 commented Dec 15, 2016

Feature Request

The HttpInterceptorService works fine with interceptors at the moment, the only downside is that all the interceptors are global and executed every time the an http request is done from the HttpInterceptorService

Proposed solution:

A way to provide interceptors and paths to intercept. So certain interceptors only apply to certain requests.

Proposed wildcards:
** to say anything after this is valid. (any number of url parts)
* to state anything after this is valid until the next /. (only a single url part)

Proposed Configuration:

CovalentHttpModule.forRoot({
      globalInterceptors: [AuthenticationInterceptor],
      pathInterceptors: [
          {interceptor: CustomInterceptor, paths: ['/apps**', '/jobs']},
          {interceptor: CustomInterceptor2, paths: ['/apps/**', '/logs/*/audit']},
        ],
    }),

This way AuthenticationInterceptor would still be applied globally, but there would be an extra configuration for interceptors and paths.

CustomInterceptor would only intercept requests done to an endpoint that contains /jobs or /apps with anything after it since ** would be a wildcard to set anything after this is ok.

CustomInterceptor2 would only intercept /apps/ and anything after it, but notice the wildcard * to state that i only care that 1 path is between logs and audit.. hence it would intercept /logs/1/audit but it would not intercept /logs/1/check/audit .

@emoralesb05
Copy link
Contributor Author

emoralesb05 commented Dec 15, 2016

We can even remove the globalInterceptors part since ** means every url and simple make it as interceptors

CovalentHttpModule.forRoot({
      inteceptors: [{
        interceptor: AuthenticationInterceptor,
        paths: ['**'],
      }, {
        interceptor: TestInterceptor,
        paths: ['/apps**'],
      }, {
        interceptor: TestInterceptor,
        paths: ['/jobs'],
      }, {
        interceptor: Test2Interceptor,
        paths: ['/apps/*/jobs**', '/logs']
      }],
    }),

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

No branches or pull requests

1 participant