豹猫可以用于组合角度应用程序和 API 还是仅适用于路由 API?



我正在使用Ocelot - API gateway for .NET Core https://github.com/ThreeMammals/Ocelot

场景:

我有以下网站

  • Ocelot API Gateway .NET Core
  • 站点 A - 角度应用
  • 站点 B - .net 核心 API
  • 站点 C - .net 核心 API

现在我想要的是所有请求都应该首先从那里到达豹猫,它将重定向到相应的应用程序和 API

请求首先从那里转到Ocelot路由应如下所述进行

/ -  route to the angular app (Site A )
/b - route to API (Site B)
/c - route to API (Site C)

我可以路由到/b 和/c 到各自的 API 和应用程序。只需要知道豹猫是否适合路由到应用程序,就像我在这里使用 Angular 一样,或者它是为微服务中的路由 API 而设计的。如果使用角度应用程序,它的优缺点是什么

我做了类似的事情,按照你的例子,它应该是这样的:

  • Ocelot API Gateway .NET Core ----> (http://entrypoint.com(
  • 站点 A - 角度应用----> (http://localhost:5001/(
  • 站点 B - .net 核心 API ----> (http://localhost:5002/b(
  • 站点 C - .net 核心 API ----> (http://localhost:5003/c(

豹猫项目中的配置:

{
"ReRoutes": [
{
"DownstreamPathTemplate": "/b/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5002
}
],
"UpstreamPathTemplate": "/b/{everything}",
"UpstreamHttpMethod": [ "Get","Post" ]
},
{
"DownstreamPathTemplate": "/c/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5003
}
],
"UpstreamPathTemplate": "/c/{everything}",
"UpstreamHttpMethod": [ "Get","Post" ]
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"UpstreamPathTemplate": "/{everything}",
"UpstreamHttpMethod": [ "Get","Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://entrypointurl.com"
}
}

裁判:

  • 豹猫入门

https://ocelot.readthedocs.io/en/latest/introduction/gettingstarted.html

  • 豹猫路由

https://ocelot.readthedocs.io/en/latest/features/routing.html

最新更新