首页 > 解决方案 > 为什么 API Gateway 在发送到我的代理时没有替换我的路径变量?

问题描述

我希望它将我的请求发送到http://<removed>/search/qweqweqweqwe,而不是http://<removed>/search/{searchString}。我究竟做错了什么?

Mon May 06 13:18:59 UTC 2019 : HTTP Method: GET, Resource Path: /search/qweqweqweqwe
Mon May 06 13:18:59 UTC 2019 : Method request path: {searchString=qweqweqweqwe}
Mon May 06 13:18:59 UTC 2019 : Method request query string: {}
Mon May 06 13:18:59 UTC 2019 : Method request headers: {}
Mon May 06 13:18:59 UTC 2019 : Method request body before transformations: 
Mon May 06 13:19:00 UTC 2019 : Endpoint request URI: http://<removed>/search/{searchString}
Mon May 06 13:19:00 UTC 2019 : Endpoint request headers: {x-amzn-apigateway-api-id=bx0tw55ts0, User-Agent=AmazonAPIGateway_bx0tw55ts0}
Mon May 06 13:19:00 UTC 2019 : Endpoint request body after transformations: 
Mon May 06 13:19:00 UTC 2019 : Sending request to http://<removed>/search/{searchString}

标签: amazon-web-servicesaws-api-gateway

解决方案


显然,如果您在 API Gateway 上使用 http_proxy,则必须在集成请求部分创建一个 URL 路径参数。一旦我添加searchString为变量 and method.request.path.searchString,它就会按预期工作。

现在我只需要弄清楚如何在 swagger api doc 中定义它并让它在导入时工作。


推荐阅读