add static file serving

This commit is contained in:
Stanley Dimant
2022-07-28 18:02:54 +02:00
parent 8f391c6afb
commit 8a3adf9c07

View File

@@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Prometheus; using Prometheus;
using WebSocketOptions = Microsoft.AspNetCore.Builder.WebSocketOptions; using WebSocketOptions = Microsoft.AspNetCore.Builder.WebSocketOptions;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
namespace MareSynchronosServer namespace MareSynchronosServer
{ {
@@ -78,6 +80,7 @@ namespace MareSynchronosServer
} }
app.UseStaticFiles(); app.UseStaticFiles();
app.UseHttpLogging();
app.UseRouting(); app.UseRouting();
var webSocketOptions = new WebSocketOptions var webSocketOptions = new WebSocketOptions
@@ -85,6 +88,13 @@ namespace MareSynchronosServer
KeepAliveInterval = TimeSpan.FromSeconds(10), KeepAliveInterval = TimeSpan.FromSeconds(10),
}; };
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(Configuration["CacheDirectory"]),
RequestPath = "/cache",
ServeUnknownFileTypes = true
});
app.UseHttpMetrics(); app.UseHttpMetrics();
app.UseWebSockets(webSocketOptions); app.UseWebSockets(webSocketOptions);