[英]ASP.NET Core gateway ocelot API doesn't work
我正在使用微服务创建一个项目,现在我希望能够测试我使用 ocelot 作为编排器创建的 API 网关,但是我无法通过浏览器对其进行测试,API 无法访问它,有人可以吗帮助?
ocelot.json:
{
"Routes": [
// Billing.API
{
"DownstreamPathTemplate": "/api/v1/Billing",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "billingapi",
"Port": "80"
}
],
"UpstreamPathTemplate": "/Billing",
"UpstreamHttpMethod": [ "GET" ]
}
]
}
当我运行项目并在浏览器中 URL 我通过/api/v1/Billing
当我通过DownstreamPathTemplate
属性。 什么都没有归还给我。
我建议先尝试通用模板,看看它是否有效:
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "billingapi",
"Port": 80,
}
],
"UpstreamPathTemplate": "/billingapi/{everything}",
"UpstreamHttpMethod": [ "Get", "Post" ]
}
来自关于下游的 Ocelot 文档:
The DownstreamPathTemplate, DownstreamScheme and DownstreamHostAndPorts define the URL that a request will be forwarded to.
对于上游:
The UpstreamPathTemplate is the URL that Ocelot will use to identify which DownstreamPathTemplate to use for a given request.
您应该在浏览器上传递 UpstreamPathTemplate URL 以路由计费 API。 在您的情况下,请求HTTP://<gateway.address>/Billings将被路由到HTTP://billingapi/api/v1/Billing 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.