Skip to content

Commit

Permalink
fix(http): rename withLegacyInterceptors to withInterceptorsFromDi (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
alxhub authored and AndrewKushnir committed Nov 4, 2022
1 parent fe0075b commit e7b48da
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions goldens/public-api/common/http/index.md
Expand Up @@ -2169,10 +2169,10 @@ export function provideHttpClient(...features: HttpFeature<HttpFeatureKind>[]):
export function withInterceptors(interceptorFns: HttpInterceptorFn[]): HttpFeature<HttpFeatureKind.Interceptors>;

// @public
export function withJsonpSupport(): HttpFeature<HttpFeatureKind.JsonpSupport>;
export function withInterceptorsFromDi(): HttpFeature<HttpFeatureKind.LegacyInterceptors>;

// @public
export function withLegacyInterceptors(): HttpFeature<HttpFeatureKind.LegacyInterceptors>;
export function withJsonpSupport(): HttpFeature<HttpFeatureKind.JsonpSupport>;

// @public
export function withNoXsrfProtection(): HttpFeature<HttpFeatureKind.NoXsrfProtection>;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/http/public_api.ts
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/common/http/src/module.ts
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -84,7 +84,7 @@ export class HttpClientXsrfModule {
*/
providers: [
provideHttpClient(
withLegacyInterceptors(),
withInterceptorsFromDi(),
withXsrfConfiguration({
cookieName: XSRF_DEFAULT_COOKIE_NAME,
headerName: XSRF_DEFAULT_HEADER_NAME,
Expand Down
4 changes: 2 additions & 2 deletions packages/common/http/src/provider.ts
Expand Up @@ -56,7 +56,7 @@ function makeHttpFeature<KindT extends HttpFeatureKind>(
* `withInterceptors(...)` feature.
*
* @see withInterceptors
* @see withLegacyInterceptors
* @see withInterceptorsFromDi
* @see withXsrfConfiguration
* @see withNoXsrfProtection
* @see withJsonpSupport
Expand Down Expand Up @@ -129,7 +129,7 @@ const LEGACY_INTERCEPTOR_FN = new InjectionToken<HttpInterceptorFn>('LEGACY_INTE
* @see HTTP_INTERCEPTORS
* @see provideHttpClient
*/
export function withLegacyInterceptors(): HttpFeature<HttpFeatureKind.LegacyInterceptors> {
export function withInterceptorsFromDi(): HttpFeature<HttpFeatureKind.LegacyInterceptors> {
// 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
Expand Down
10 changes: 5 additions & 5 deletions packages/common/http/test/provider_spec.ts
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('provideHttp', () => {
withInterceptors([
makeLiteralTagInterceptorFn('functional'),
]),
withLegacyInterceptors(),
withInterceptorsFromDi(),
),
provideHttpClientTesting(),
provideLegacyInterceptor('legacy'),
Expand All @@ -161,7 +161,7 @@ describe('provideHttp', () => {
TestBed.configureTestingModule({
providers: [
provideHttpClient(
withLegacyInterceptors(),
withInterceptorsFromDi(),
withInterceptors([
makeLiteralTagInterceptorFn('functional'),
]),
Expand Down

0 comments on commit e7b48da

Please sign in to comment.