You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 satır
1.8KB

  1. using Microsoft.Extensions.Configuration;
  2. using Serilog;
  3. using TelpoKafkaConsole.Model;
  4. using TelpoKafkaConsole.Service;
  5. using TelpoKafkaConsole.WebApi.Configs;
  6. using TelpoKafkaConsole.WebApi.Middleware;
  7. namespace TelpoKafkaConsole.WebApi
  8. {
  9. public class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13. //Ñ¡ÔñÅäÖÃÎļþappsetting.json
  14. var config = new ConfigurationBuilder()
  15. .SetBasePath(Directory.GetCurrentDirectory())
  16. .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  17. .Build();
  18. Log.Logger = new LoggerConfiguration()
  19. .ReadFrom.Configuration(config).Enrich.WithThreadInfo()
  20. .CreateLogger();
  21. var builder = WebApplication.CreateBuilder(args);
  22. // Add services to the container.
  23. builder.Services.AddControllers();
  24. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  25. builder.Services.AddEndpointsApiExplorer();
  26. builder.Services.AddSwaggerGen();
  27. #region ÅäÖÃÐÅÏ¢
  28. builder.Services
  29. .Configure<ServiceConfig>(builder.Configuration.GetSection("ServiceConfig"));
  30. #endregion
  31. builder.Services.AddSingleton<KafkaAdminService>();
  32. builder.Host.UseSerilog();
  33. var app = builder.Build();
  34. // Configure the HTTP request pipeline.
  35. if (app.Environment.IsDevelopment())
  36. {
  37. app.UseSwagger();
  38. app.UseSwaggerUI();
  39. }
  40. app.UseAuthorization();
  41. app.UseMiddleware<LoggingMiddleware>();
  42. app.MapControllers();
  43. app.Run();
  44. }
  45. }
  46. }