This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new a8e0c67 apigateway should always append request.path if response type
is http (#4056)
a8e0c67 is described below
commit a8e0c673c8762ec95d75a19e0839afa5eff345f5
Author: Carlos Santana <[email protected]>
AuthorDate: Mon Oct 15 16:13:56 2018 -0400
apigateway should always append request.path if response type is http
(#4056)
* apigateway should always append request.path if response type is http
* address feedback handle logic in makeWebActionBackendUrl
---
core/routemgmt/common/apigw-utils.js | 6 +++---
tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/core/routemgmt/common/apigw-utils.js
b/core/routemgmt/common/apigw-utils.js
index 26df324..fe70170 100644
--- a/core/routemgmt/common/apigw-utils.js
+++ b/core/routemgmt/common/apigw-utils.js
@@ -566,7 +566,7 @@ function setActionOperationInvocationDetails(swagger,
endpoint, operationId, res
var caseIdx = getCaseOperationIdx(caseArr, operationId);
var operations = [operationId];
_.set(swagger,
'x-ibm-configuration.assembly.execute[0].operation-switch.case['+caseIdx+'].operations',
operations);
- _.set(swagger,
'x-ibm-configuration.assembly.execute[0].operation-switch.case['+caseIdx+'].execute[0].invoke.target-url',
makeWebActionBackendUrl(endpoint.action, responsetype,
getPathParameters(endpoint.gatewayPath)));
+ _.set(swagger,
'x-ibm-configuration.assembly.execute[0].operation-switch.case['+caseIdx+'].execute[0].invoke.target-url',
makeWebActionBackendUrl(endpoint.action, responsetype, true) );
_.set(swagger,
'x-ibm-configuration.assembly.execute[0].operation-switch.case['+caseIdx+'].execute[0].invoke.verb',
'keep');
if (endpoint.action.secureKey) {
_.set(swagger,
'x-ibm-configuration.assembly.execute[0].operation-switch.case['+caseIdx+'].execute[1].set-variable.actions[0].set',
'message.headers.X-Require-Whisk-Auth' );
@@ -599,12 +599,12 @@ function getCaseOperationIdx(caseArr, operationId) {
// parameters - the parameters defined in the path, if any.
// Returns:
// string - web-action URL
-function makeWebActionBackendUrl(endpointAction, endpointResponseType,
parameters) {
+function makeWebActionBackendUrl(endpointAction, endpointResponseType,
isTargetUrl = false) {
host = getHostFromActionUrl(endpointAction.backendUrl);
ns = endpointAction.namespace;
pkg = getPackageNameFromFqActionName(endpointAction.name) || 'default';
name = getActionNameFromFqActionName(endpointAction.name);
- reqPath = parameters != null && parameters.length > 0 ? "$(request.path)" :
"";
+ reqPath = isTargetUrl && endpointResponseType === 'http' ? "$(request.path)"
: "";
return 'https://' + host + '/api/v1/web/' + ns + '/' + pkg + '/' + name +
'.' + endpointResponseType + reqPath;
}
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
index 2c41afa..ec212ce 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
@@ -202,7 +202,7 @@ class ApiGwRestTests extends ApiGwRestBasicTests with
RestUtil with WskActorSyst
val openwhisk = RestResult.getFieldJsObject(urlop, "x-openwhisk")
val actionN = RestResult.getField(openwhisk, "action")
actionN shouldBe actionName
- rr.stdout should include regex
(s""""target-url":\\s*".*${actionName}.${responseType}"""")
+ rr.stdout should include regex
(s""""target-url":\\s*".*${actionName}.${responseType}.*"""")
}
override def verifyInvalidSwagger(rr: RunResult): Unit = {