Skip to content

Commit 46323a5

Browse files
authored
Feature/syn 766 (#129)
* Added a ‘AddTrailingSlashToRequestUri’ JavaScript policy * Fixed case * Renamed file so Git detects case change in filename * And changinbg filename back to detect case change in filename * Using var instead of let (EcmaScript 1.7) * Moved the step for ‘javascript.AddTrailingSlashToRequestUri’ in to the ‘TargetEndpoint > PreFlow > Request’ * Updated “request.uri” to be “proxy.pathsuffix” * Trying “target.url” instead of “proxy.pathsuffix” * Moving the policy to the TargetEndpoint PostFlow Request * Setting pathWithTrailingSlash
1 parent bb11432 commit 46323a5

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

proxies/live/apiproxy/policies/javascript.AddTrailingSlashToRequestUri.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="javascript.AddTrailingSlashToTargetPath">
3+
<DisplayName>javascript.AddTrailingSlashToTargetPath</DisplayName>
4+
<Properties/>
5+
<ResourceURL>jsc://AddTrailingSlashToTargetPath.js</ResourceURL>
6+
</Javascript>

proxies/live/apiproxy/resources/jsc/AddTrailingSlashToRequestUri.js

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var proxyPathSuffix = context.getVariable("proxy.pathsuffix");
2+
if (proxyPathSuffix.charAt(proxyPathSuffix.length - 1) === "/") {
3+
context.setVariable("pathWithTrailingSlash", proxyPathSuffix);
4+
} else {
5+
context.setVariable("pathWithTrailingSlash", proxyPathSuffix + "/");
6+
}
7+
8+
context.setVariable("target.copy.pathsuffix", false);

proxies/live/apiproxy/targets/target.xml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<TargetEndpoint name="nhs-website-content-api-target">
22
<PreFlow>
33
<Request>
4-
<Step>
5-
<Name>javascript.AddTrailingSlashToRequestUri</Name>
6-
</Step>
74
<Step>
85
<Name>VerifyAPIKey.FromHeader</Name>
96
</Step>
@@ -35,6 +32,15 @@
3532
<Condition/>
3633
</Flow>
3734
</Flows>
35+
<PostFlow>
36+
<Request>
37+
<Step>
38+
<Name>javascript.AddTrailingSlashToTargetPath</Name>
39+
</Step>
40+
</Request>
41+
<Response>
42+
</Response>
43+
</PostFlow>
3844
<FaultRules>
3945
<FaultRule name="api_key_invalid">
4046
<Condition>verifyapikey.VerifyAPIKey.FromHeader.failed</Condition>
@@ -44,7 +50,7 @@
4450
<SSLInfo>
4551
<Enabled>true</Enabled>
4652
</SSLInfo>
47-
<Path>/content-api</Path>
53+
<Path>/content-api/{pathWithTrailingSlash}</Path>
4854
<LoadBalancer>
4955
<Server name= "{{ NHS_CONTENT_API_TARGET_SERVER }}" />
5056
</LoadBalancer>

0 commit comments

Comments
 (0)