Skip to content

Commit 1918bdd

Browse files
committed
Minor refactorings
1 parent 1fb81f1 commit 1918bdd

File tree

8 files changed

+50
-80
lines changed

8 files changed

+50
-80
lines changed

Exchange.Rates.CoinCap.OpenApi/Exchange.Rates.CoinCap.OpenApi.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
</PropertyGroup>
1313
<ItemGroup>
1414
<PackageReference Include="MassTransit.AspNetCore" Version="7.3.1" />
15-
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
15+
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
1616
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.10" />
1717
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
1818
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.10" />
1919
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
2020
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2121
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
22-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
23-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.8.1" />
22+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
23+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.9.0" />
2424
</ItemGroup>
2525
<ItemGroup>
2626
<Folder Include="Log\" />

Exchange.Rates.CoinCap.Polling.Api/Exchange.Rates.CoinCap.Polling.Api.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="MassTransit.AspNetCore" Version="7.3.1" />
19-
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
19+
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
2020
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.10" />
2121
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
2222
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Exchange.Rates.Ecb.OpenApi/Exchange.Rates.Ecb.OpenApi.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="MassTransit.AspNetCore" Version="7.3.1" />
17-
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
17+
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
1818
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.10" />
1919
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
2020
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.10" />
2121
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
2222
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2323
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
24-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
25-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.8.1" />
24+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
25+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.9.0" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

Exchange.Rates.Ecb.Polling.Api/Exchange.Rates.Ecb.Polling.Api.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="MassTransit.AspNetCore" Version="7.3.1" />
19-
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
19+
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
2020
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.10" />
2121
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
2222
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Exchange.Rates.Gateway/Exchange.Rates.Gateway.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
</PropertyGroup>
88
<ItemGroup>
99
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
10-
<PackageReference Include="Ocelot" Version="23.3.4" />
10+
<PackageReference Include="Ocelot.Cache.CacheManager" Version="23.3.4" />
11+
<PackageReference Include="Ocelot.Provider.Polly" Version="23.3.4" />
1112
</ItemGroup>
1213
<ItemGroup>
1314
<Content Update="appsettings.json">
14-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
15+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1516
</Content>
1617
</ItemGroup>
1718
<ItemGroup>

Exchange.Rates.Gateway/Program.cs

+38-26
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
1-
using Microsoft.AspNetCore;
21
using Microsoft.AspNetCore.Hosting;
32
using Microsoft.Extensions.Configuration;
3+
using Microsoft.Extensions.Hosting;
4+
using Microsoft.Extensions.Logging;
5+
using Ocelot.Cache.CacheManager;
6+
using Ocelot.DependencyInjection;
7+
using Ocelot.Middleware;
8+
using Ocelot.Provider.Polly;
49
using System.IO;
510

6-
namespace Exchange.Rates.Gateway;
7-
8-
public class Program
9-
{
10-
public static void Main(string[] args)
11+
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
12+
.UseContentRoot(Directory.GetCurrentDirectory())
13+
.ConfigureWebHostDefaults(webBuilder =>
1114
{
12-
BuildWebHost(args).Run();
13-
}
14-
15-
public static IWebHost BuildWebHost(string[] args) =>
16-
WebHost.CreateDefaultBuilder(args)
17-
.UseKestrel()
18-
.UseContentRoot(Directory.GetCurrentDirectory())
19-
.ConfigureAppConfiguration((hostingContext, config) =>
20-
{
21-
config
22-
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
23-
.AddJsonFile("appsettings.json", true, true)
24-
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
25-
.AddJsonFile("ocelot.json", optional: false, reloadOnChange: false)
26-
.AddJsonFile($"ocelot.{hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true)
27-
.AddEnvironmentVariables();
28-
})
29-
.UseStartup<Startup>()
30-
.Build();
31-
}
15+
webBuilder.ConfigureServices(services =>
16+
services
17+
.AddOcelot()
18+
.AddCacheManager(x =>
19+
{
20+
x.WithDictionaryHandle();
21+
})
22+
.AddPolly());
23+
webBuilder.Configure(app =>
24+
app.UseOcelot().Wait())
25+
.ConfigureAppConfiguration((hostingContext, config) =>
26+
{
27+
config
28+
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
29+
.AddJsonFile("appsettings.json", false, true)
30+
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
31+
.AddJsonFile("ocelot.json", false, true)
32+
.AddJsonFile($"ocelot.{hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true)
33+
.AddEnvironmentVariables();
34+
})
35+
.ConfigureLogging((builderContext, logging) =>
36+
{
37+
logging.ClearProviders();
38+
logging.AddConsole();
39+
logging.AddDebug();
40+
});
41+
});
3242

43+
IHost host = hostBuilder.Build();
44+
await host.RunAsync();

Exchange.Rates.Gateway/Startup.cs

-44
This file was deleted.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ And access **Ecb API** through API Gateway:
225225
226226
## Testing
227227
Test project includes both Unit and Integration tests:
228+
228229
![](res/Tests.jpg)
229230
230231
## Conclusion

0 commit comments

Comments
 (0)