提供給台大案英特拉線上繳費填寫發票資訊用
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

57 рядки
1.4KB

  1. using Altob.NtuInvoiceGateway.Middleware;
  2. using Altob.NtuInvoiceGateway.Models;
  3. using Serilog;
  4. var builder = WebApplication.CreateBuilder(args);
  5. builder.Host.UseSerilog((context, services, configuration) =>
  6. {
  7. configuration
  8. .ReadFrom.Configuration(context.Configuration)
  9. .Enrich.FromLogContext()
  10. .Enrich.WithProperty("ServiceName", "NtuInvoiceGateway");
  11. });
  12. // Add services to the container.
  13. builder.Services.AddRazorPages();
  14. builder.Services.AddHttpClient();
  15. // Configure company info
  16. builder.Services.Configure<Altob.NtuInvoiceGateway.Models.CompanyInfo>(
  17. builder.Configuration.GetSection("CompanyInfo"));
  18. builder.Services.Configure<Altob.NtuInvoiceGateway.Models.InvoiceApiOptions>(
  19. builder.Configuration.GetSection("InvoiceApi"));
  20. builder.Services.Configure<IpWhitelistOptions>(
  21. builder.Configuration.GetSection("IpWhitelist"));
  22. var app = builder.Build();
  23. try
  24. {
  25. // Configure the HTTP request pipeline.
  26. if (!app.Environment.IsDevelopment())
  27. {
  28. app.UseExceptionHandler("/Error");
  29. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  30. app.UseHsts();
  31. }
  32. app.UseHttpsRedirection();
  33. app.UseRouting();
  34. app.UseMiddleware<IpWhitelistMiddleware>();
  35. app.UseAuthorization();
  36. app.MapStaticAssets();
  37. app.MapRazorPages()
  38. .WithStaticAssets();
  39. app.Run();
  40. }
  41. finally
  42. {
  43. Log.CloseAndFlush();
  44. }