(string[] args)
| 26 | using System.Threading.RateLimiting; |
| 27 | |
| 28 | public partial class Program |
| 29 | { |
| 30 | public static void Main(string[] args) |
| 31 | { |
| 32 | var builder = WebApplication.CreateBuilder(args); |
| 33 | builder.WebHost.ConfigureKestrel(options => |
| 34 | { |
| 35 | options.AddServerHeader = false; |
| 36 | |
| 37 | // Set to 1/4 of the default value to better support mobile devices on slow networks |
| 38 | options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 60, gracePeriod: TimeSpan.FromSeconds(10)); |
| 39 | }); |
| 40 | |
| 41 | builder.Logging.ClearProviders(); |
| 42 | builder.Logging.AddConsole(); |
| 43 | |
| 44 | var appEnv = EnvSettings.Load(); |
| 45 | |
| 46 | builder.Services.AddResponseCompression(options => |
| 47 | { |
| 48 | options.EnableForHttps = true; |
| 49 | }); |
| 50 | |
| 51 | builder.Services.AddCors(options => |
| 52 | { |
| 53 | options.AddPolicy(name: "AllowAptabaseCom", policy => |
| 54 | { |
| 55 | policy.WithOrigins("https://aptabase.com") |
| 56 | .WithMethods("GET") |
| 57 | .AllowCredentials() |
| 58 | .SetPreflightMaxAge(TimeSpan.FromHours(1)); |
| 59 | }); |
| 60 | |
| 61 | options.AddPolicy(name: "AllowAny", policy => |
| 62 | { |
| 63 | policy.AllowAnyOrigin() |
| 64 | .WithHeaders("content-type", "app-key") |
| 65 | .WithMethods("POST", "OPTIONS") |
| 66 | .SetPreflightMaxAge(TimeSpan.FromHours(1)); |
| 67 | }); |
| 68 | }); |
| 69 | |
| 70 | if (appEnv.IsManagedCloud) |
| 71 | { |
| 72 | builder.Services.AddDataProtection() |
| 73 | .PersistKeysToAWSSystemsManager("/aptabase/production/aspnet-dataprotection/"); |
| 74 | } |
| 75 | |
| 76 | builder.Services.AddControllers(); |
| 77 | builder.Services.AddResponseCaching(); |
| 78 | |
| 79 | builder.Services.AddMemoryCache(); |
| 80 | builder.Services.AddHttpContextAccessor(); |
| 81 | builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) |
| 82 | .AddCookie(options => |
| 83 | { |
| 84 | options.ExpireTimeSpan = TimeSpan.FromDays(365); |
| 85 | options.Cookie.Name = "auth-session"; |
nothing calls this directly
no test coverage detected