Adding features
This commit is contained in:
@@ -4,11 +4,37 @@ using Fragalytics.Web.Services;
|
||||
using Fragalytics.Web.Services.Parser;
|
||||
using Fragalytics.Web.Services.Render;
|
||||
using Fragalytics.Web.Services.Scoring;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var contentRoot = AppPathResolver.ResolveContentRoot(Directory.GetCurrentDirectory(), AppContext.BaseDirectory);
|
||||
var webRoot = Path.Combine(contentRoot, "wwwroot");
|
||||
|
||||
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
||||
{
|
||||
Args = args,
|
||||
ContentRootPath = contentRoot,
|
||||
WebRootPath = Directory.Exists(webRoot) ? webRoot : null
|
||||
});
|
||||
|
||||
builder.Services.Configure<FragalyticsOptions>(builder.Configuration.GetSection("Fragalytics"));
|
||||
var uploadMaxBytes = builder.Configuration.GetValue<long?>("Fragalytics:UploadMaxBytes") ?? 536_870_912;
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.Limits.MaxRequestBodySize = uploadMaxBytes;
|
||||
});
|
||||
builder.Services.Configure<FormOptions>(options =>
|
||||
{
|
||||
options.MultipartBodyLengthLimit = uploadMaxBytes;
|
||||
});
|
||||
var dataProtectionRoot = Path.GetFullPath(Path.Combine(contentRoot, builder.Configuration["Fragalytics:DataDirectory"] ?? "data", "keys"));
|
||||
Directory.CreateDirectory(dataProtectionRoot);
|
||||
|
||||
builder.Services
|
||||
.AddDataProtection()
|
||||
.SetApplicationName("Fragalytics.Web")
|
||||
.PersistKeysToFileSystem(new DirectoryInfo(dataProtectionRoot));
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddSingleton<JsonAppStore>();
|
||||
builder.Services.AddSingleton<ScoringRulesProvider>();
|
||||
|
||||
Reference in New Issue
Block a user