如何使用Spring Cloud函数为使用Java的Http请求调用谷歌云函数

时间:2021-05-03 11:21:19

标签: spring-boot google-cloud-platform google-cloud-functions spring-cloud-function

我正在尝试使用 Spring Cloud Function for Http Request 实现 Google Cloud Function,但是我找不到任何可以帮助我理解如何处理 Http Request 的示例示例。在 AWS 中,我们有 APIGatewayProxyRequestEventAPIGatewayProxyResponseEvent,如下所示:

    @Bean
    public Function<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> processXmlOrder() {
      return value -> {
        try {     
          APIGatewayProxyResponseEvent responseEvent = new APIGatewayProxyResponseEvent();
          responseEvent.setStatusCode(201);
          responseEvent.setBody(objectMapper.writeValueAsString(order));
          return responseEvent;
        } catch (IOException e) {
          ......
        }
      };
    }

Documentation example 只解释了如何读取字符串并响应字符串。如果我必须阅读 Http Request 并映射到 Google Http Request 并使用 Google Http Respond 响应怎么办?我们如何使用 Spring Cloud Function for Http Request 在 GCP Cloud Function 中创建类似的函数?

文档中没有解释 GCP Cloud Function 与 Spring Cloud Function 集成的文章。

0 个答案:

没有答案