Skip to content

Commit

Permalink
Merge pull request #54 from NHSDigital/NPA-2273_Add_404_Response
Browse files Browse the repository at this point in the history
NPA-2273 Add 404 Not Found Response
  • Loading branch information
chris-young-12-nhs authored Apr 22, 2024
2 parents c03bcad + 9d313f5 commit e78d2a1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.

This file was deleted.

This file was deleted.

42 changes: 42 additions & 0 deletions proxies/live/apiproxy/policies/RaiseFault.404NotFound.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This policy raises a 404 error response for an invalid resource request.
Raisefault policies stop the execution of the current flow and move to the error flow, which returns the error response defined here to the requesting application.
For more information on RaiseFault policies within Apigee see the following resource:
* https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy
-->
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.404NotFound">
<DisplayName>RaiseFault.404NotFound</DisplayName>
<Properties/>
<FaultResponse>
<Set>
<Headers/>
<StatusCode>404</StatusCode>
<ReasonPhrase>NotFound</ReasonPhrase>
<Payload>
{
"issue": [
{
"code": "processing",
"details": {
"coding": [
{
"code": "INVALIDATED_RESOURCE",
"display": "Resource that has been marked as invalid was requested - invalid resources cannot be retrieved",
"system": "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode",
"version": "1"
}
]
},
"severity": "error"
}
],
"resourceType": "OperationOutcome"
}
</Payload>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
17 changes: 7 additions & 10 deletions proxies/live/apiproxy/targets/target.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,20 @@
</Response>
</PostFlow>
<FaultRules>
<FaultRule name="404_Not_Found">
<Step>
<Name>RaiseFault.404NotFound</Name>
</Step>
<Condition>response.header.x-amzn-ErrorType = "IncompleteSignatureException"</Condition>
</FaultRule>
<FaultRule name="unauthorized">
<Step>
<Name>RaiseFault.401Unauthorized</Name>
<Condition>
oauthV2.OauthV2.VerifyAccessToken.failed = true or fault.name = "invalid_access_token" or fault.name = "InvalidAccessToken" or fault.name = "access_token_not_approved" or fault.name = "apiresource_doesnot_exist" or fault.name = "InvalidAPICallAsNo" or fault.name = "ApiProductMatchFound"
oauthV2.OauthV2.VerifyAccessToken.failed = true or fault.name = "invalid_access_token" or fault.name = "InvalidAccessToken" or fault.name = "access_token_not_approved" or fault.name = "apiresource_doesnot_exist" or fault.name = "InvalidAPICallAsNo" or fault.name = "ApiProductMatchFound" or fault.name = "access_token_expired"
</Condition>
</Step>
</FaultRule>
<FaultRule name="access_token_expired">
<Step>
<Name>ExtractVariables.OAuthErrorFaultString</Name>
</Step>
<Step>
<Name>AssignMessage.OAuthPolicyErrorResponse</Name>
</Step>
<Condition>oauthV2.OauthV2.VerifyAccessToken.failed</Condition>
</FaultRule>
</FaultRules>
<HTTPTargetConnection>
<LoadBalancer>
Expand Down

0 comments on commit e78d2a1

Please sign in to comment.