1
0
mirror of https://github.com/CyberL1/MyMcRealms.git synced 2024-09-19 16:02:51 -04:00

feat: public directory

This commit is contained in:
CyberL1 2024-04-21 11:43:33 +02:00
parent c93673367a
commit fbf2e8b9bb
2 changed files with 20 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.FileProviders;
using MyMcRealms.Data; using MyMcRealms.Data;
using MyMcRealms.Helpers; using MyMcRealms.Helpers;
using MyMcRealms.Middlewares; 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 // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();
builder.Services.AddDirectoryBrowser();
var dataSourceBuilder = new NpgsqlDataSourceBuilder(Environment.GetEnvironmentVariable("CONNECTION_STRING")); var dataSourceBuilder = new NpgsqlDataSourceBuilder(Environment.GetEnvironmentVariable("CONNECTION_STRING"));
dataSourceBuilder.EnableDynamicJson(); dataSourceBuilder.EnableDynamicJson();
@ -50,5 +52,21 @@ if (app.Environment.IsDevelopment())
app.UseMiddleware<MinecraftCookieMiddleware>(); app.UseMiddleware<MinecraftCookieMiddleware>();
app.MapControllers(); 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(); app.Run();

View File

@ -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`