我是WebFlux和Serverless的新手。我正在尝试通过AWS API网关创建一个REST API作为无服务器。
流程是API Gateway --> Lambda --> DynamoDB
为了实现API流程,Spring Cloud函数会是最佳选择吗?我发现aws-serverless-java-container无缝地完成了这项工作(将事件转换为http请求/响应的包装器)
我已经阅读了关于http://cloud.spring.io/spring-cloud-function/single/spring-cloud-function.html的文档和在https://github.com/spring-cloud/spring-cloud-function中找到的一些示例。但是,我仍然不确定使用Spring Cloud Function是否能够实现API风格。
@Bean
//How path or query params can be mapped?
public Function<Flux<String>, Flux<String>> getEmployeeDetails() {
// business logic goes here
}
在上面的代码片段中,如何实现GET请求/响应模型。如果我的端点有/{dept}/{employee}/{name},Spring cloud function如何接受GET请求中的路径参数?
任何提示都会很有帮助。
发布于 2019-01-14 03:59:47
API Gateway将传入请求的所有数据封装到一个APIGatewayProxyRequestEvent对象中,该对象具有多个属性,如请求体、路径和查询参数,或者原始请求的HTTP方法。对于您的用例,您将获得三个路径参数dept、employee和name。
然而,问题是在传入的APIGatewayProxyRequestEvent和您的函数之间进行映射的SpringBootApiGatewayRequestHandler目前只考虑请求正文,而根本不考虑其他参数。
我希望开发人员将来能解决这个问题。同时,您可以实现SpringBootApiGatewayRequestHandler的修改版本,该版本考虑了所需的参数。我写了一篇小文章,which covers exactly this topic。
https://stackoverflow.com/questions/51325366
复制相似问题