|
3 | 3 | using Microsoft.EntityFrameworkCore; |
4 | 4 | using Microsoft.OpenApi.Models; |
5 | 5 |
|
6 | | -namespace CapTest.Depot.Host |
| 6 | +namespace CapTest.Depot.Host; |
| 7 | + |
| 8 | +public class Startup |
7 | 9 | { |
8 | | - public class Startup |
| 10 | + public Startup(IConfiguration configuration) |
| 11 | + { |
| 12 | + Configuration = configuration; |
| 13 | + } |
| 14 | + |
| 15 | + #region Properties |
| 16 | + |
| 17 | + public IConfiguration Configuration { get; } |
| 18 | + |
| 19 | + #endregion |
| 20 | + |
| 21 | + #region Methods |
| 22 | + |
| 23 | + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
| 24 | + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
9 | 25 | { |
10 | | - public Startup(IConfiguration configuration) |
| 26 | + if (env.IsDevelopment()) |
11 | 27 | { |
12 | | - Configuration = configuration; |
| 28 | + _ = app.UseDeveloperExceptionPage(); |
| 29 | + _ = app.UseSwagger(); |
| 30 | + _ = app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "CapTest.Depot.Host v1")); |
13 | 31 | } |
14 | 32 |
|
15 | | - public IConfiguration Configuration { get; } |
| 33 | + _ = app.UseHttpsRedirection(); |
16 | 34 |
|
17 | | - // This method gets called by the runtime. Use this method to add services to the container. |
18 | | - public void ConfigureServices(IServiceCollection services) |
19 | | - { |
20 | | - services.AddTransient<OrderCreatedEventHandler>(); |
| 35 | + _ = app.UseRouting(); |
21 | 36 |
|
22 | | - services.AddControllers(); |
23 | | - services.AddSwaggerGen(c => |
| 37 | + _ = app.UseAuthorization(); |
| 38 | + |
| 39 | + _ = app.UseEndpoints( |
| 40 | + endpoints => |
24 | 41 | { |
25 | | - c.SwaggerDoc("v1", new OpenApiInfo { Title = "CapTest.Depot.Host", Version = "v1" }); |
| 42 | + _ = endpoints.MapControllers(); |
26 | 43 | }); |
| 44 | + } |
27 | 45 |
|
28 | | - services.AddDbContextPool<DepotDbContext>(builder => |
29 | | - builder.UseNpgsql(Configuration.GetConnectionString(DepotConsts.DbContextConnName))); |
| 46 | + // This method gets called by the runtime. Use this method to add services to the container. |
| 47 | + public void ConfigureServices(IServiceCollection services) |
| 48 | + { |
| 49 | + _ = services.AddTransient<OrderCreatedEventHandler>(); |
30 | 50 |
|
31 | | - services.AddCap(options => |
| 51 | + _ = services.AddControllers(); |
| 52 | + _ = services.AddSwaggerGen( |
| 53 | + c => |
32 | 54 | { |
33 | | - options.TopicNamePrefix = "test"; |
34 | | - |
35 | | - options.UseEntityFramework<DepotDbContext>(efOptions => efOptions.Schema = "cap"); |
36 | | - |
37 | | - options.UseRabbitMQ(mqOptions => |
38 | | - { |
39 | | - mqOptions.HostName = "localhost"; |
40 | | - //mqOptions.Port = ; |
41 | | - //mqOptions.UserName = ""; |
42 | | - //mqOptions.Password = ""; |
43 | | - }); |
44 | | - |
45 | | - options.UseDashboard(dashboardOptions => dashboardOptions.PathMatch = "/cap"); |
46 | | - //options.UseDiscovery(discoveryOptions => { }); |
| 55 | + c.SwaggerDoc("v1", new OpenApiInfo { Title = "CapTest.Depot.Host", Version = "v1" }); |
47 | 56 | }); |
48 | | - } |
49 | 57 |
|
50 | | - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
51 | | - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
52 | | - { |
53 | | - if (env.IsDevelopment()) |
54 | | - { |
55 | | - app.UseDeveloperExceptionPage(); |
56 | | - app.UseSwagger(); |
57 | | - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "CapTest.Depot.Host v1")); |
58 | | - } |
| 58 | + _ = services.AddDbContextPool<DepotDbContext>( |
| 59 | + builder => builder.UseNpgsql(Configuration.GetConnectionString(DepotConsts.DbContextConnName))); |
59 | 60 |
|
60 | | - app.UseHttpsRedirection(); |
| 61 | + _ = services.AddCap( |
| 62 | + options => |
| 63 | + { |
| 64 | + options.TopicNamePrefix = "test"; |
61 | 65 |
|
62 | | - app.UseRouting(); |
| 66 | + _ = options.UseEntityFramework<DepotDbContext>(efOptions => efOptions.Schema = "cap"); |
63 | 67 |
|
64 | | - app.UseAuthorization(); |
| 68 | + _ = options.UseRabbitMQ( |
| 69 | + mqOptions => |
| 70 | + { |
| 71 | + mqOptions.HostName = "localhost"; |
| 72 | + //mqOptions.Port = ; |
| 73 | + //mqOptions.UserName = ""; |
| 74 | + //mqOptions.Password = ""; |
| 75 | + }); |
65 | 76 |
|
66 | | - app.UseEndpoints(endpoints => |
67 | | - { |
68 | | - endpoints.MapControllers(); |
| 77 | + _ = options.UseDashboard(dashboardOptions => dashboardOptions.PathMatch = "/cap"); |
69 | 78 | }); |
70 | | - } |
71 | 79 | } |
| 80 | + |
| 81 | + #endregion |
| 82 | + |
72 | 83 | } |
0 commit comments