GH-861 Add constant for aws-context

Resolves #861
This commit is contained in:
Oleg Zhurakousky
2022-04-21 13:16:02 +02:00
parent 5e1b8d3912
commit 047c0b1e6d
2 changed files with 10 additions and 1 deletions

View File

@@ -37,6 +37,13 @@ public class FuncApplication implements ApplicationContextInitializer<GenericApp
}
```
== AWS Context
In a typical implementation of AWS Handler user has access to AWS _context_ object. With function approach you can have the same experience if you need it.
Upon each invocation the framework will add `aws-context` message header containing the AWS _context_ instance for that particular invocation. So if you need to access it
you can simply have `Message<YourPojo>` as an input parameter to your function and then access `aws-context` from message headers.
For convenience we provide AWSLambdaUtils.AWS_CONTEXT constant.
== Platform Specific Features
=== HTTP and API Gateway

View File

@@ -51,6 +51,8 @@ final class AWSLambdaUtils {
static final String AWS_API_GATEWAY = "aws-api-gateway";
public static final String AWS_CONTEXT = "aws-context";
private AWSLambdaUtils() {
}
@@ -136,7 +138,7 @@ final class AWSLambdaUtils {
messageBuilder = MessageBuilder.withPayload(payload);
}
if (awsContext != null) {
messageBuilder.setHeader("aws-context", awsContext);
messageBuilder.setHeader(AWS_CONTEXT, awsContext);
}
logger.info("Incoming request headers: " + headers);