api - GCP API Gateway:路径参数作为查询参数传递
问题描述
我正在尝试使用 GCP API Gateway 为我的几个后端服务(A、B、C、D)创建一个端点,每个端点都有自己的路径结构。我为以下服务之一配置了网关:
swagger: '2.0'
info:
title: <TITLE>
description: <DESC>
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
/service_a/match/{id_}:
get:
summary: <SUMMARY>
description: <DESC>
operationId: match_id_
parameters:
- required: true
type: string
name: id_
in: path
- required: true
type: boolean
default: false
name: bool_first
in: query
- required: false
type: boolean
default: false
name: bool_Second
in: query
x-google-backend:
address: <cloud_run_url>/match/{id_}
deadline: 60.0
responses:
'200':
description: Successful Response
'422':
description: Validation
这部署得很好。但是当我到达端点时gateway_url/service_a/match/123
,它会被路由到cloud_run_url/match/%7Bid_%7D?id_=123
而不是cloud_run_url/match/123
.
我怎样才能解决这个问题?
解决方案
编辑我的答案,因为我误解了这个问题。
似乎{
从您的配置中泄漏为 ASCII 代码,所以当您调用
x-google-backend:
address: <cloud_run_url>/match/{id_}
deadline: 60.0
它没有显示正确的 ID。
因此,这应该是您的文件中的泄漏问题,您可以使用与此线程中有关使用路径参数yaml
的相同方式来解决此问题
推荐阅读
- r - Error in calculating standard error: (list) object cannot be coerced to type 'double'
- reporting-services - 基于参数选择的 SSRS 报表动态分页
- python - 我们可以在列表中找到素数吗?
- amazon-web-services - 除非执行 /index,否则 aws 静态网站 SSL 将无法工作
- python - 编写一个 evenNumOfOdds (L) 函数,它接受正整数 L 的列表,如果 L 中有偶数个奇数,则返回 True
- c - 要求用户输入 ... 使用 Scanf
- json - 以特定方式在 Excel 中解析 JSON 嵌套数组
- cluster-computing - 具有奇点的 Snakemake
- python - Spacy 实体链接训练 - KeyError
- python - 将列表中的 0 值替换为递增数字,从该列表中的最高数字开始