We have developed two ASP.NET CORE (5.0) microservices and deployed them inside docker http://localhost:28621/stock http://localhost:62362/user
Both are easily accessible from browser.
We have used ocelot gateway for API gateway. When we deployed it inside docker we got following error
warn: Ocelot.DownstreamRouteFinder.Middleware.DownstreamRouteFinderMiddleware[0] requestId: 0HM8658EF6KHC:00000002, previousRequestId: no previous request id, message: DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /user, verb: GET. warn: Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId: 0HM8658EF6KHC:00000002, previousRequestId: no previous request id, message: Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /user, verb: GET. errors found in ResponderMiddleware. Setting error response for request path:/user, request method: GET -------------------------------------------------------------------------------------------------
ocelot.Development.json is as follows
{
"Routes": [
{
"DownstreamPathTemplate": "/user",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 62362
}
],
"UpstreamPathTemplate": "/user",
"UpstreamHttpMethod": [ "Get" ]
},
{
"DownstreamPathTemplate": "/stock",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 28621
}
],
"UpstreamPathTemplate": "/stock",
"UpstreamHttpMethod": [ "Get" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:5021"
}
}
startup.cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot();
}
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
await app.UseOcelot();
}
}
program.cs
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddJsonFile($"ocelot.
{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
Please guide us where we are doing mistake we are using .net core 5.0
Thanks