Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging messages to CF api rewrite function. #264

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions service/terraform/aws/api_uri_rewrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function handler(event) {
while (incomingUri.indexOf("//") >= 0) {
incomingUri = incomingUri.replace("//","/");
}

// Put the URI back into the request now in case the rewrite doesn't happen
request.uri = incomingUri

Expand All @@ -48,11 +49,16 @@ function handler(event) {
newUri += "/" + uriParts[i];
}

// write the updated URI and the new HTTP header to the request only
// if things check out to this point
// set updated URI into request and set request node header
request.uri = newUri;
request.headers['x-request-node'] = { "value" : resultHeader };
console.log("incoming URI [" + incomingUri + "] rewritten to [" + newUri
+ "] & x-request-node [" + resultHeader + "]")
} else {
console.log("incoming URI [" + incomingUri + "] : no rewrite (no command)")
}
} else {
console.log("incoming URI [" + incomingUri + "] : no rewrite (no prefix match)")
}

return request;
Expand Down