14
14
15
15
namespace Exchange . Rates . CoinCap . OpenApi ;
16
16
17
- public class Startup
17
+ public class Startup ( IConfiguration configuration )
18
18
{
19
19
private const string SERVICE_NAME = "Exchange.Rates.CoinCap.OpenApi" ;
20
20
21
- public Startup ( IConfiguration configuration )
22
- {
23
- Configuration = configuration ;
24
- }
25
-
26
- public IConfiguration Configuration { get ; set ; }
21
+ public IConfiguration Configuration { get ; set ; } = configuration ;
27
22
28
23
public virtual void ConfigureServices ( IServiceCollection services )
29
24
{
@@ -60,29 +55,29 @@ public virtual void ConfigureServices(IServiceCollection services)
60
55
// Add MassTransit support
61
56
services . AddMassTransit ( x =>
62
57
{
63
- x . AddBus ( _ => Bus . Factory . CreateUsingRabbitMq ( config =>
58
+ x . AddRequestClient < ISubmitCoinCapAssetId > ( ) ;
59
+ x . UsingRabbitMq ( ( config , rabbitBusConfig ) =>
64
60
{
65
- config . Host ( new Uri ( massTransitOptions [ nameof ( MassTransitOptions . Host ) ] ) , h =>
61
+ rabbitBusConfig . Host ( new Uri ( massTransitOptions [ nameof ( MassTransitOptions . Host ) ] ) , rabbitHostConfig =>
66
62
{
67
- h . Username ( massTransitOptions [ nameof ( MassTransitOptions . Username ) ] ) ;
68
- h . Password ( massTransitOptions [ nameof ( MassTransitOptions . Password ) ] ) ;
63
+ rabbitHostConfig . Username ( massTransitOptions [ nameof ( MassTransitOptions . Username ) ] ) ;
64
+ rabbitHostConfig . Password ( massTransitOptions [ nameof ( MassTransitOptions . Password ) ] ) ;
69
65
} ) ;
70
- } ) ) ;
71
- x . AddRequestClient < ISubmitCoinCapAssetId > ( ) ;
66
+ } ) ;
72
67
} ) ;
73
68
74
69
services . AddControllers ( )
75
- . ConfigureApiBehaviorOptions ( options =>
76
- {
77
- options . SuppressConsumesConstraintForFormFileParameters = true ;
78
- options . SuppressInferBindingSourcesForParameters = true ;
79
- options . SuppressModelStateInvalidFilter = true ; // To disable the automatic 400 behavior, set the SuppressModelStateInvalidFilter property to true
80
- options . SuppressMapClientErrors = true ;
81
- options . ClientErrorMapping [ 404 ] . Link = "https://httpstatuses.com/404" ;
82
- } )
83
- . AddNewtonsoftJson ( options =>
84
- options . SerializerSettings . ReferenceLoopHandling = Newtonsoft . Json . ReferenceLoopHandling . Ignore
85
- ) ;
70
+ . ConfigureApiBehaviorOptions ( options =>
71
+ {
72
+ options . SuppressConsumesConstraintForFormFileParameters = true ;
73
+ options . SuppressInferBindingSourcesForParameters = true ;
74
+ options . SuppressModelStateInvalidFilter = true ; // To disable the automatic 400 behavior, set the SuppressModelStateInvalidFilter property to true
75
+ options . SuppressMapClientErrors = true ;
76
+ options . ClientErrorMapping [ 404 ] . Link = "https://httpstatuses.com/404" ;
77
+ } )
78
+ . AddNewtonsoftJson ( options =>
79
+ options . SerializerSettings . ReferenceLoopHandling = Newtonsoft . Json . ReferenceLoopHandling . Ignore
80
+ ) ;
86
81
87
82
services . AddCors ( ) ;
88
83
services . AddRouting ( options => options . LowercaseUrls = true ) ;
@@ -119,10 +114,10 @@ public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
119
114
configure . MapDefaultControllerRoute ( ) ;
120
115
// Redirect root to Swagger UI
121
116
configure . MapGet ( "" , context =>
122
- {
123
- context . Response . Redirect ( "./swagger/index.html" , permanent : false ) ;
124
- return Task . FromResult ( 0 ) ;
125
- } ) ;
117
+ {
118
+ context . Response . Redirect ( "./swagger/index.html" , permanent : false ) ;
119
+ return Task . CompletedTask ;
120
+ } ) ;
126
121
} ) ;
127
122
}
128
- }
123
+ }
0 commit comments