From e7b48da713f32c02c096f1342ab8b0d7ec696ca5 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Fri, 28 Oct 2022 01:01:51 -0700 Subject: [PATCH] fix(http): rename `withLegacyInterceptors` to `withInterceptorsFromDi` (#47901) This rename reflects what the function actually does. Although the intention is still not to have two different interceptor mechanisms, that is now communicated in the docs for the function instead of in its name. Fixes #47764 PR Close #47901 --- goldens/public-api/common/http/index.md | 4 ++-- packages/common/http/public_api.ts | 2 +- packages/common/http/src/module.ts | 4 ++-- packages/common/http/src/provider.ts | 4 ++-- packages/common/http/test/provider_spec.ts | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/goldens/public-api/common/http/index.md b/goldens/public-api/common/http/index.md index 9609f27496e00..f1e1010dfc1b1 100644 --- a/goldens/public-api/common/http/index.md +++ b/goldens/public-api/common/http/index.md @@ -2169,10 +2169,10 @@ export function provideHttpClient(...features: HttpFeature[]): export function withInterceptors(interceptorFns: HttpInterceptorFn[]): HttpFeature; // @public -export function withJsonpSupport(): HttpFeature; +export function withInterceptorsFromDi(): HttpFeature; // @public -export function withLegacyInterceptors(): HttpFeature; +export function withJsonpSupport(): HttpFeature; // @public export function withNoXsrfProtection(): HttpFeature; diff --git a/packages/common/http/public_api.ts b/packages/common/http/public_api.ts index e8e98ccb7de64..a1e1d58c335d7 100644 --- a/packages/common/http/public_api.ts +++ b/packages/common/http/public_api.ts @@ -35,7 +35,7 @@ export {HTTP_INTERCEPTORS, HttpInterceptor, HttpInterceptorHandler as ɵHttpInte export {JsonpClientBackend, JsonpInterceptor} from './src/jsonp'; export {HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule} from './src/module'; export {HttpParameterCodec, HttpParams, HttpParamsOptions, HttpUrlEncodingCodec} from './src/params'; -export {HttpFeature, HttpFeatureKind, provideHttpClient, withJsonpSupport, withLegacyInterceptors, withNoXsrfProtection, withXsrfConfiguration, withInterceptors, withRequestsMadeViaParent} from './src/provider'; +export {HttpFeature, HttpFeatureKind, provideHttpClient, withJsonpSupport, withNoXsrfProtection, withXsrfConfiguration, withInterceptors, withInterceptorsFromDi, withRequestsMadeViaParent} from './src/provider'; export {HttpRequest} from './src/request'; export {HttpDownloadProgressEvent, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpResponseBase, HttpSentEvent, HttpStatusCode, HttpUploadProgressEvent, HttpUserEvent} from './src/response'; export {HttpXhrBackend} from './src/xhr'; diff --git a/packages/common/http/src/module.ts b/packages/common/http/src/module.ts index dffc63763aed9..1388302dec18e 100644 --- a/packages/common/http/src/module.ts +++ b/packages/common/http/src/module.ts @@ -9,7 +9,7 @@ import {ModuleWithProviders, NgModule} from '@angular/core'; import {HTTP_INTERCEPTORS} from './interceptor'; -import {provideHttpClient, withJsonpSupport, withLegacyInterceptors, withNoXsrfProtection, withXsrfConfiguration} from './provider'; +import {provideHttpClient, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withXsrfConfiguration} from './provider'; import {HttpXsrfCookieExtractor, HttpXsrfInterceptor, HttpXsrfTokenExtractor, XSRF_DEFAULT_COOKIE_NAME, XSRF_DEFAULT_HEADER_NAME, XSRF_ENABLED} from './xsrf'; /** @@ -84,7 +84,7 @@ export class HttpClientXsrfModule { */ providers: [ provideHttpClient( - withLegacyInterceptors(), + withInterceptorsFromDi(), withXsrfConfiguration({ cookieName: XSRF_DEFAULT_COOKIE_NAME, headerName: XSRF_DEFAULT_HEADER_NAME, diff --git a/packages/common/http/src/provider.ts b/packages/common/http/src/provider.ts index 0c1aa7aeec961..e2037be03a1e9 100644 --- a/packages/common/http/src/provider.ts +++ b/packages/common/http/src/provider.ts @@ -56,7 +56,7 @@ function makeHttpFeature( * `withInterceptors(...)` feature. * * @see withInterceptors - * @see withLegacyInterceptors + * @see withInterceptorsFromDi * @see withXsrfConfiguration * @see withNoXsrfProtection * @see withJsonpSupport @@ -129,7 +129,7 @@ const LEGACY_INTERCEPTOR_FN = new InjectionToken('LEGACY_INTE * @see HTTP_INTERCEPTORS * @see provideHttpClient */ -export function withLegacyInterceptors(): HttpFeature { +export function withInterceptorsFromDi(): HttpFeature { // Note: the legacy interceptor function is provided here via an intermediate token // (`LEGACY_INTERCEPTOR_FN`), using a pattern which guarantees that if these providers are // included multiple times, all of the multi-provider entries will have the same instance of the diff --git a/packages/common/http/test/provider_spec.ts b/packages/common/http/test/provider_spec.ts index 5639317f9f31f..693c9f66a4673 100644 --- a/packages/common/http/test/provider_spec.ts +++ b/packages/common/http/test/provider_spec.ts @@ -14,7 +14,7 @@ import {TestBed} from '@angular/core/testing'; import {EMPTY, Observable} from 'rxjs'; import {HttpInterceptorFn} from '../src/interceptor'; -import {provideHttpClient, withInterceptors, withJsonpSupport, withLegacyInterceptors, withNoXsrfProtection, withRequestsMadeViaParent, withXsrfConfiguration} from '../src/provider'; +import {provideHttpClient, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXsrfConfiguration} from '../src/provider'; describe('provideHttp', () => { beforeEach(() => { @@ -62,10 +62,10 @@ describe('provideHttp', () => { req.flush(''); }); - it('withLegacyInterceptors() should enable legacy interceptors', () => { + it('withInterceptorsFromDi() should enable legacy interceptors', () => { TestBed.configureTestingModule({ providers: [ - provideHttpClient(withLegacyInterceptors()), + provideHttpClient(withInterceptorsFromDi()), provideLegacyInterceptor('alpha'), provideLegacyInterceptor('beta'), provideHttpClientTesting(), @@ -144,7 +144,7 @@ describe('provideHttp', () => { withInterceptors([ makeLiteralTagInterceptorFn('functional'), ]), - withLegacyInterceptors(), + withInterceptorsFromDi(), ), provideHttpClientTesting(), provideLegacyInterceptor('legacy'), @@ -161,7 +161,7 @@ describe('provideHttp', () => { TestBed.configureTestingModule({ providers: [ provideHttpClient( - withLegacyInterceptors(), + withInterceptorsFromDi(), withInterceptors([ makeLiteralTagInterceptorFn('functional'), ]),