Skip to content

Commit 1141690

Browse files
Include header in the file/function name for consistency
1 parent 9655557 commit 1141690

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/server/index.jsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import getAgent from './utilities/getAgent';
3434
import { getMvtExperiments, getMvtVaryHeaders } from './utilities/mvtHeader';
3535
import getAssetOrigins from './utilities/getAssetOrigins';
3636
import extractHeaders from './utilities/extractHeaders';
37-
import addPlatformToRequestChain from './utilities/addPlatformToRequestChain';
37+
import addPlatformToRequestChainHeader from './utilities/addPlatformToRequestChainHeader';
3838

3939
const morgan = require('morgan');
4040

@@ -161,8 +161,11 @@ const injectDefaultCacheHeader = (req, res, next) => {
161161
next();
162162
};
163163

164-
const injectPlatformToRequestChain = (req, res, next) => {
165-
res.set('req-svc-chain', addPlatformToRequestChain({ headers: req.headers }));
164+
const injectPlatformToRequestChainHeader = (req, res, next) => {
165+
res.set(
166+
'req-svc-chain',
167+
addPlatformToRequestChainHeader({ headers: req.headers }),
168+
);
166169
next();
167170
};
168171

@@ -198,7 +201,7 @@ server.get(
198201
injectDefaultCacheHeader,
199202
injectReferrerPolicyHeader,
200203
injectResourceHintsHeader,
201-
injectPlatformToRequestChain,
204+
injectPlatformToRequestChainHeader,
202205
],
203206
async ({ url, query, headers, path: urlPath }, res) => {
204207
let derivedPageType = 'Unknown';

src/server/utilities/addPlatformToRequestChain/index.test.ts src/server/utilities/addPlatformToRequestChainHeader/index.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import addPlatformToRequestChain from '.';
1+
import addPlatformToRequestChainHeader from '.';
22

33
describe('addPlatformToRequestChain', () => {
44
it('appends SIMORGH to the req-svc-chain header if it exists', () => {
55
const headers = { 'req-svc-chain': 'SERVICE_1,SERVICE_2' };
6-
const result = addPlatformToRequestChain({
6+
const result = addPlatformToRequestChainHeader({
77
headers,
88
});
99

@@ -12,7 +12,7 @@ describe('addPlatformToRequestChain', () => {
1212

1313
it('does not append SIMORGH to the req-svc-chain header if it is the final service', () => {
1414
const headers = { 'req-svc-chain': 'SERVICE_1,SERVICE_2,SIMORGH' };
15-
const result = addPlatformToRequestChain({
15+
const result = addPlatformToRequestChainHeader({
1616
headers,
1717
});
1818

@@ -21,7 +21,7 @@ describe('addPlatformToRequestChain', () => {
2121

2222
it('returns SIMORGH if the req-svc-chain header does not exist', () => {
2323
const headers = { 'header-name': 'header-value' };
24-
const result = addPlatformToRequestChain({
24+
const result = addPlatformToRequestChainHeader({
2525
headers,
2626
});
2727

ws-nextjs-app/middleware.page.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable import/prefer-default-export */
22
import { NextResponse, NextRequest } from 'next/server';
33

4-
import addPlatformToRequestChain from '#server/utilities/addPlatformToRequestChain';
4+
import addPlatformToRequestChainHeader from '#server/utilities/addPlatformToRequestChainHeader';
55
import cspHeaderResponse from './utilities/cspHeaderResponse';
66

77
const LOCALHOST_DOMAINS = ['localhost', '127.0.0.1'];
@@ -22,7 +22,7 @@ export function middleware(request: NextRequest) {
2222

2323
response.headers.set(
2424
'req-svc-chain',
25-
addPlatformToRequestChain({
25+
addPlatformToRequestChainHeader({
2626
headers: request.headers,
2727
}),
2828
);

0 commit comments

Comments
 (0)