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.

Program.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using HealthMonitor.Common;
  2. using HealthMonitor.Common.helper;
  3. using HealthMonitor.Model.Config;
  4. using HealthMonitor.Service.Biz.db;
  5. namespace HealthMonitor.WebApi
  6. {
  7. public class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var builder = WebApplication.CreateBuilder(args);
  12. // Add services to the container.
  13. builder.Services.AddHttpClient(Consts.DEFAULT_HTTPCLIENT_NAME, c =>
  14. {
  15. c.Timeout = TimeSpan.FromSeconds(10); //ʱ
  16. c.DefaultRequestHeaders.Add("Accept", "application/json");
  17. //c.DefaultRequestHeaders.Connection.Add("keep-alive");
  18. });
  19. builder.Services.Configure<TDengineServiceConfig>(builder.Configuration.GetSection("TDengineServiceConfig"));
  20. builder.Services.AddSingleton<HttpHelper>();
  21. builder.Services.AddSingleton<TDengineService>();
  22. builder.Services.AddControllers();
  23. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  24. builder.Services.AddEndpointsApiExplorer();
  25. builder.Services.AddSwaggerGen();
  26. var app = builder.Build();
  27. // Configure the HTTP request pipeline.
  28. if (app.Environment.IsDevelopment())
  29. {
  30. app.UseSwagger();
  31. app.UseSwaggerUI();
  32. }
  33. app.UseHttpsRedirection();
  34. app.UseAuthorization();
  35. app.MapControllers();
  36. app.Run();
  37. }
  38. }
  39. }