-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
46 lines (30 loc) · 993 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Net6_Demo.Helpers;
using Net6_Demo.Extensions;
using Net6_Demo.Workers;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddLogging(logger =>
{
//add custom logger
logger.AddRabbitMQLogger();
});
builder.Services.Configure<RabbitMQSetting>(builder.Configuration.GetSection(nameof(RabbitMQSetting)));
builder.Services.AddHostedService<BackgroundTask>();
builder.Services.AddSingleton<IWorker, ConsumeWorker>();
builder.Services.AddSingleton<RabbitMQHelper>();
builder.Services.AddControllers();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new() { Title = "Net6_Demo", Version = "v1" });
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Net6_Demo v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();