Add json file called ocelot.json
in your project and default configuration are as below
{
"ReRoutes": [
{
"DownStreamPathTemplate": "api/WeatherForecast",
"DownStreamScheme": "http",
"DownStreamHostAndPorts": [
{
"Host": "localhost",
"Post": 7020
}
],
"UpStreamPathTemplate": "/WeatherForecast",
"UpStreamHttpMethod": [ "GET" ]
}
]
}
Then do configure like this in Program.cs
:
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("ocelot.json")
.Build();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOcelot(configuration);
var app = builder.Build();
app.UseOcelot();
app.Run();
Hope it helps you.Happy Learning !
Thank you
No comments:
Post a Comment