Skip to content

Commit 4a2eebd

Browse files
update naming
1 parent 19b70c2 commit 4a2eebd

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import { FeatureFlagTracingOptions } from "./requestTracing/FeatureFlagTracingOp
6262
import { AIConfigurationTracingOptions } from "./requestTracing/AIConfigurationTracingOptions.js";
6363
import { KeyFilter, LabelFilter, SettingSelector } from "./types.js";
6464
import { ConfigurationClientManager } from "./ConfigurationClientManager.js";
65-
import { ETAG_LOOKUP_HEADER } from "./EtagUrlPipelinePolicy.js";
65+
import { CDN_TOKEN_LOOKUP_HEADER } from "./EtagUrlPipelinePolicy.js";
6666
import { getFixedBackoffDuration, getExponentialBackoffDuration } from "./common/backoffUtils.js";
6767
import { InvalidOperationError, ArgumentError, isFailoverableError, isInputError } from "./common/error.js";
6868

@@ -507,7 +507,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
507507
if (this.#isCdnUsed && selectorCollection.cdnToken) {
508508
listOptions = {
509509
...listOptions,
510-
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: selectorCollection.cdnToken }}
510+
requestOptions: { customHeaders: { [CDN_TOKEN_LOOKUP_HEADER]: selectorCollection.cdnToken }}
511511
};
512512
}
513513
const pageEtags: string[] = [];
@@ -618,7 +618,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
618618
// If CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
619619
let getOptions: GetConfigurationSettingOptions = {};
620620
if (this.#isCdnUsed && this.#kvSelectorCollection.cdnToken) {
621-
getOptions = { requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnToken } } };
621+
getOptions = { requestOptions: { customHeaders: { [CDN_TOKEN_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnToken } } };
622622
}
623623
const response = await this.#getConfigurationSetting(sentinel, getOptions);
624624
sentinel.etag = response?.etag;
@@ -680,7 +680,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
680680
if (this.#isCdnUsed && this.#kvSelectorCollection.cdnToken) {
681681
// if CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
682682
getOptions = {
683-
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnToken ?? "" } },
683+
requestOptions: { customHeaders: { [CDN_TOKEN_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnToken ?? "" } },
684684
};
685685
}
686686
// send conditional request only when CDN is not used
@@ -754,7 +754,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
754754
// If CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
755755
listOptions = {
756756
...listOptions,
757-
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: selectorCollection.cdnToken } }
757+
requestOptions: { customHeaders: { [CDN_TOKEN_LOOKUP_HEADER]: selectorCollection.cdnToken } }
758758
};
759759
}
760760

src/EtagUrlPipelinePolicy.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33

44
import { PipelinePolicy } from "@azure/core-rest-pipeline";
55

6-
export const ETAG_LOOKUP_HEADER = "Etag-Lookup";
6+
export const CDN_TOKEN_LOOKUP_HEADER = "cdn-token-lookup";
77

88
/**
9-
* The pipeline policy that retrieves the etag from the request header and appends it to the request URL. After that the etag header is removed from the request.
9+
* The pipeline policy that retrieves the CDN token from the request header and appends it to the request URL. After that the lookup header is removed from the request.
1010
* @remarks
1111
* The policy position should be perCall.
12-
* The App Configuration service will not recognize the etag query parameter in the url, but this can help to break the CDN cache as the cache entry is based on the URL.
12+
* The App Configuration service will not recognize the CDN token query parameter in the url, but this can help to break the CDN cache as the cache entry is based on the URL.
1313
*/
14-
export class EtagUrlPipelinePolicy implements PipelinePolicy {
15-
name: string = "AppConfigurationEtagUrlPolicy";
14+
export class CdnTokenPipelinePolicy implements PipelinePolicy {
15+
name: string = "AppConfigurationCdnTokenPolicy";
1616

1717
async sendRequest(request, next) {
18-
if (request.headers.has(ETAG_LOOKUP_HEADER)) {
19-
const etag = request.headers.get(ETAG_LOOKUP_HEADER);
20-
request.headers.delete(ETAG_LOOKUP_HEADER);
18+
if (request.headers.has(CDN_TOKEN_LOOKUP_HEADER)) {
19+
const token = request.headers.get(CDN_TOKEN_LOOKUP_HEADER);
20+
request.headers.delete(CDN_TOKEN_LOOKUP_HEADER);
2121

2222
const url = new URL(request.url);
23-
url.searchParams.append("_", etag); // _ is a dummy query parameter to break the CDN cache
23+
url.searchParams.append("_", token); // _ is a dummy query parameter to break the CDN cache
2424
request.url = url.toString();
2525
}
2626

src/load.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AzureAppConfiguration } from "./AzureAppConfiguration.js";
66
import { AzureAppConfigurationImpl } from "./AzureAppConfigurationImpl.js";
77
import { AzureAppConfigurationOptions } from "./AzureAppConfigurationOptions.js";
88
import { ConfigurationClientManager } from "./ConfigurationClientManager.js";
9-
import { EtagUrlPipelinePolicy } from "./EtagUrlPipelinePolicy.js";
9+
import { CdnTokenPipelinePolicy } from "./EtagUrlPipelinePolicy.js";
1010
import { instanceOfTokenCredential } from "./common/utils.js";
1111
import { ArgumentError } from "./common/error.js";
1212

@@ -93,7 +93,7 @@ export async function loadFromCdn(
9393
// Add etag url policy to append etag to the request url for breaking CDN cache
9494
additionalPolicies: [
9595
...(appConfigOptions.clientOptions?.additionalPolicies || []),
96-
{ policy: new EtagUrlPipelinePolicy(), position: "perCall" }
96+
{ policy: new CdnTokenPipelinePolicy(), position: "perCall" }
9797
]
9898
};
9999

0 commit comments

Comments
 (0)