如何使AWS API Gateway请求路径不区分大小写 [英] How to make the AWS API Gateway request path case insensitive
问题描述
AWS API网关中的请求路径设置似乎区分大小写.谁能建议任何解决方案以使请求路径不区分大小写
It seems that the request path setup in AWS API gateway is case sensitive. Can anyone suggest any solution to make the request path to be case insensitive
例如:可以访问 https://api-gw.some-domain/health 无法访问 https://api-gw.some-domain/Health .(404)
For example: https://api-gw.some-domain/health is accessible whereas https://api-gw.some-domain/Health is not accessible. (404)
推荐答案
不幸的是,像大多数AWS产品一样,API网关在设计上也区分大小写.
Unfortunately API Gateway, like most of AWS' offerings, is case-sensitive by design.
因此,您有两个选择:
-
使用CloudFront和Lambda @ Edge来重写您的请求(这涉及很多,但是可以在这里找到一个很好的教程:使用 BasePath映射和
Use BasePath mapping and a Proxy Resource so that you can have a single lambda that receives all requests and then dispatches/responds accordingy.
我建议使用CloudFront方法,因为它更便宜且易于维护.但是,对于小型API,您可能会想尝试第二种方法,特别是如果您可以将整个API托管在一个lambda中.
I would recommend the CloudFront approach, as its cheaper and easier to maintain. However for a small API you might be tempted to go for the second, especially if you can host the whole API in a single lambda.
n.b.互联网区分大小写(大多数情况下是小写),例如: http://www.bbc.co.uk/news/world-europe-12083491 与 查看全文