Menu Close
6.6.10. 在 3scale 产品自定义资源中配置网关响应
作为 3scale 管理员,您可以配置 产品自定义资源,以指定对对该 API 产品
公开 API 的请求的网关响应。部署 CR 后,3scale 确保网关返回您指定的响应和错误消息。
在 Product
CR 中,gatewayResponse
对象包含您希望网关返回的响应。
步骤
在新的或已部署的
Product
CR 中,在gatewayResponse
对象中配置一个或多个响应。以下示例显示了使用名为userKey
的身份验证模式的 Apicast 托管部署的响应配置:apiVersion: capabilities.3scale.net/v1beta1 kind: Product metadata: name: product1 spec: name: "OperatedProduct 1" deployment: apicastHosted: authentication: userkey: gatewayResponse: errorStatusAuthFailed: 500 errorHeadersAuthFailed: "text/plain; charset=mycharset" errorAuthFailed: "My custom reponse body" errorStatusAuthMissing: 500 errorHeadersAuthMissing: "text/plain; charset=mycharset" errorAuthMissing: "My custom reponse body" errorStatusNoMatch: 501 errorHeadersNoMatch: "text/plain; charset=mycharset" errorNoMatch: "My custom reponse body" errorStatusLimitsExceeded: 502 errorHeadersLimitsExceeded: "text/plain; charset=mycharset" errorLimitsExceeded: "My custom reponse body"
部署包含网关响应
的产品
CR。例如,如果您更新了product1.yaml
文件,请运行以下命令:oc create -f product1.yaml
对于给定示例,输出为:
product.capabilities.3scale.net/product1 created