如何返回与无服务器+ OpenWhisk背后IBM云API网关非200个HTTP状态代码?

问题描述 投票:0回答:1

我无法弄清楚如何为函数返回的HTTP状态代码的API GW后面。不管是什么我回来,它总是回来为200。我已经试过statusCodecode无济于事。

我使用的是与OpenWhisk插件无服务器架构。我部署到IBM云。

openwhisk
1个回答
2
投票

网络行动响应内容类型参数必须设置为http手动configure the HTTP response。此值默认为json而忽略返回headersstatusCode值。

在无服务器框架,该值在YAML的event configuration section设置。

functions:
  my_function:
    handler: index.main
    events:
      - http:
          method: GET
          path: /api/greeting
          resp: http
© www.soinside.com 2019 - 2024. All rights reserved.