【发布时间】:2019-05-31 14:06:04
【问题描述】:
我查看了https://docs.micronaut.io/latest/guide/index.html#functionBean 的micronaut 文档,所有示例都假设事件来自API Gateway,并且请求正文作为POJO 发送。 Micronaut 是否还可以支持 S3Event 和所有其他 AWS Lambda 事件类型的无服务器功能?示例:https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html#with-s3-example-deployment-pkg-java
可以支持以下内容吗?我没有找到 AWS 通常期望在 Micronaut 中的 java 函数如何映射到 RequestHandler<S3Event, String>。
package example;
import io.micronaut.function.FunctionBean;
import java.util.function.Consumer;
@FunctionBean("hello-world-java")
public class HelloJavaFunction implements Function<S3Event, String> {
@Override
public String apply(S3Event) {
return "Hello world!";
}
}
【问题讨论】:
-
您的实现看起来正确。你试过吗?函数 bean 的名称必须以
micronaut.function.name的形式出现在application.yml中(从 CLI 生成函数时默认完成)
标签: aws-lambda micronaut