diff --git a/MyMcRealms/Program.cs b/MyMcRealms/Program.cs index ad96af4..80bfc5d 100644 --- a/MyMcRealms/Program.cs +++ b/MyMcRealms/Program.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.FileProviders; using MyMcRealms.Data; using MyMcRealms.Helpers; using MyMcRealms.Middlewares; @@ -25,6 +26,7 @@ builder.Services.AddControllers().AddJsonOptions(x => x.JsonSerializerOptions.Re // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +builder.Services.AddDirectoryBrowser(); var dataSourceBuilder = new NpgsqlDataSourceBuilder(Environment.GetEnvironmentVariable("CONNECTION_STRING")); dataSourceBuilder.EnableDynamicJson(); @@ -50,5 +52,21 @@ if (app.Environment.IsDevelopment()) app.UseMiddleware(); app.MapControllers(); +app.UseStaticFiles(); + +var fileProvider = new PhysicalFileProvider(Path.Combine(builder.Environment.WebRootPath, "public")); +var requestPath = "/public"; + +app.UseStaticFiles(new StaticFileOptions +{ + FileProvider = fileProvider, + RequestPath = requestPath +}); + +app.UseDirectoryBrowser(new DirectoryBrowserOptions +{ + FileProvider = fileProvider, + RequestPath = requestPath +}); app.Run(); diff --git a/MyMcRealms/wwwroot/public/README.txt b/MyMcRealms/wwwroot/public/README.txt new file mode 100644 index 0000000..dd551e4 --- /dev/null +++ b/MyMcRealms/wwwroot/public/README.txt @@ -0,0 +1,2 @@ +This directory ~~is~~ will be used for plugin files serving. +Plugin files will be named in the following way: `MyMcRealms-MC_VERSION.jar` \ No newline at end of file