some work (need to thing about client and server data model as next step)
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
using OwnChar.Data;
|
||||
using OwnChar.Plugins;
|
||||
using OwnChar.ServerNew.Api.Endpoint;
|
||||
using OwnChar.ServerNew.Api.Endpoint.Implementations;
|
||||
using OwnChar.ServerNew.Api.Plugins;
|
||||
using Pilz.Configuration;
|
||||
using Pilz.Plugins;
|
||||
using Pilz.Plugins.Advanced;
|
||||
|
||||
namespace OwnChar.ServerNew;
|
||||
|
||||
@@ -24,46 +19,18 @@ internal class Program
|
||||
// Create server context
|
||||
var server = new ServerContext(SettingsManager.Instance);
|
||||
|
||||
// Load log
|
||||
// ...
|
||||
|
||||
// Load plugins
|
||||
server.Log.Debug("Loading plugins");
|
||||
var pluginPath = Path.Combine(AppTempFolder, "Plugins");
|
||||
Directory.CreateDirectory(pluginPath);
|
||||
var pluginPaths = Directory.GetDirectories(pluginPath, "*", SearchOption.TopDirectoryOnly).Select(n => Path.Combine(n, n + ".dll")).ToArray();
|
||||
OwnCharPlugins.Instance.LoadPlugins(pluginPaths, new OwnCharServerPluginInitParams(server));
|
||||
var plugins = OwnCharPlugins.Instance.LoadPlugins(pluginPaths, new OwnCharServerPluginInitParams(server));
|
||||
server.Log.InfoFormat("{0} plugins loaded", plugins.Count());
|
||||
|
||||
// Add services to the container.
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
// Build app
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAuthorization();
|
||||
|
||||
// Built-in endpoints
|
||||
var apibuilder = new ApiBuilder(app);
|
||||
new LoginApi(server).Initialize(apibuilder);
|
||||
new UsersApi(server).Initialize(apibuilder);
|
||||
new GroupsApi(server).Initialize(apibuilder);
|
||||
new CharactersApi(server).Initialize(apibuilder);
|
||||
|
||||
// Plugin endpoints
|
||||
var endpoints = PluginFeatureController.Instance.Features.Get(ApiEndpointFeature.FeatureType).OfType<IApiEndpoint>();
|
||||
if (endpoints.Any())
|
||||
{
|
||||
foreach (var endpoint in endpoints)
|
||||
endpoint.Initialize(apibuilder);
|
||||
}
|
||||
|
||||
// Run server
|
||||
app.Run();
|
||||
// Start server app
|
||||
server.Start(args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user