|
- using Microsoft.Extensions.Configuration;
- using Serilog;
- using TelpoKafkaConsole.Model;
- using TelpoKafkaConsole.Service;
- using TelpoKafkaConsole.WebApi.Configs;
- using TelpoKafkaConsole.WebApi.Middleware;
-
- namespace TelpoKafkaConsole.WebApi
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- //Ñ¡ÔñÅäÖÃÎļþappsetting.json
- var config = new ConfigurationBuilder()
- .SetBasePath(Directory.GetCurrentDirectory())
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .Build();
- Log.Logger = new LoggerConfiguration()
- .ReadFrom.Configuration(config).Enrich.WithThreadInfo()
- .CreateLogger();
-
-
-
-
- var builder = WebApplication.CreateBuilder(args);
-
- // Add services to the container.
-
- builder.Services.AddControllers();
- // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
- builder.Services.AddEndpointsApiExplorer();
- builder.Services.AddSwaggerGen();
-
- #region ÅäÖÃÐÅÏ¢
- builder.Services
- .Configure<ServiceConfig>(builder.Configuration.GetSection("ServiceConfig"));
- #endregion
-
-
- builder.Services.AddSingleton<KafkaAdminService>();
-
-
-
- builder.Host.UseSerilog();
-
- var app = builder.Build();
-
- // Configure the HTTP request pipeline.
- if (app.Environment.IsDevelopment())
- {
- app.UseSwagger();
- app.UseSwaggerUI();
- }
-
- app.UseAuthorization();
-
- app.UseMiddleware<LoggingMiddleware>();
-
- app.MapControllers();
-
- app.Run();
- }
- }
- }
|