summaryrefslogtreecommitdiffstats
path: root/src/Program.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2023-01-16 22:36:58 +0100
committerivarlovlie <git@ivarlovlie.no>2023-01-16 22:36:58 +0100
commitcc1a2f82a7b560fddcbe74db66aad2e399594862 (patch)
tree6a7e42a9597fc767bb699b8e81709eb3be6fb1aa /src/Program.cs
parent8a7c318f6273c51ea1b96c87f98b0320ef339e16 (diff)
downloadblob-bin-cc1a2f82a7b560fddcbe74db66aad2e399594862.tar.xz
blob-bin-cc1a2f82a7b560fddcbe74db66aad2e399594862.zip
feat: Div
Diffstat (limited to 'src/Program.cs')
-rw-r--r--src/Program.cs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Program.cs b/src/Program.cs
index 29b0fe1..68e7785 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -2,16 +2,33 @@ global using BlobBin;
using System.Text;
using System.Text.Json;
using IOL.Helpers;
+using Serilog;
+using Serilog.Events;
using File = BlobBin.File;
const long MAX_REQUEST_BODY_SIZE = 104_857_600;
var builder = WebApplication.CreateBuilder(args);
+var logger = new LoggerConfiguration()
+ .MinimumLevel.Information()
+ .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
+ .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information)
+ .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Information)
+ .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
+ .WriteTo.Console();
+Log.Logger = logger.CreateLogger();
+Log.Information("Starting web host");
+builder.Host.UseSerilog(Log.Logger);
builder.Services.AddDbContext<Db>();
builder.Services.AddHostedService<WallE>();
builder.WebHost.UseKestrel(o => { o.Limits.MaxRequestBodySize = MAX_REQUEST_BODY_SIZE; });
var app = builder.Build();
app.UseFileServer();
app.UseStatusCodePages();
+app.UseSerilogRequestLogging();
+if (app.Environment.IsProduction()) {
+ app.UseForwardedHeaders();
+}
+
app.MapGet("/upload-link", GetFileUploadLink);
app.MapPost("/file/{id}", UploadFilePart);
app.MapPost("/file", UploadFile);
@@ -66,7 +83,7 @@ IResult DeleteUpload(HttpContext context, Db db, string id, string key = default
db.SaveChanges();
return Results.Text("""
-The file is marked for deletion and cannot be accessed any more, all traces off it will be gone from our systems within 7 days.
+The upload is marked for deletion and cannot be accessed any more, all traces off it will be gone from our systems within 7 days.
""");
}
@@ -123,7 +140,7 @@ To delete the file, open this url in a browser {context.Request.GetRequestHost()
""");
}
-IResult UploadFilePart(HttpContext context, Db db) {
+IResult UploadFilePart(HttpContext context, Db db, Guid id) {
return Results.Ok();
}