Plugin features - Added PluginFeature attribute

Plugin features -Added PluginFeatureInfo to plugin features
Web server - Moved REST APIs to plugins
This commit is contained in:
SpoinkyNL committed 2021-01-30 21:55:29 +01:00
1 parent 46958338b9
commit c1b0027231
18 files changed
+297 -183

No files matched your search

@@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
namespace Artemis.Core.Services
{
internal class PluginsController : WebApiController
{
private readonly IWebServerService _webServerService;
public PluginsController(IWebServerService webServerService)
{
_webServerService = webServerService;
}
[Route(HttpVerbs.Get, "/plugins/endpoints")]
public IReadOnlyCollection<PluginEndPoint> GetPluginEndPoints()
{
return _webServerService.PluginsModule.PluginEndPoints;
}
[Route(HttpVerbs.Get, "/plugins/endpoints/{plugin}/{endPoint}")]
public PluginEndPoint GetPluginEndPoint(Guid plugin, string endPoint)
{
PluginEndPoint? pluginEndPoint = _webServerService.PluginsModule.PluginEndPoints.FirstOrDefault(e => e.PluginFeature.Plugin.Guid == plugin && e.Name == endPoint);
if (pluginEndPoint == null)
throw HttpException.NotFound();
return pluginEndPoint;
}
}
}
@@ -52,8 +52,6 @@ namespace Artemis.Core.Services
.HandleHttpException((context, exception) => HandleHttpExceptionJson(context, exception))
.HandleUnhandledException(JsonExceptionHandlerCallback);
// Add built-in core controllers to the API module
apiModule.RegisterController(() => _kernel.Get<PluginsController>());
// Add registered controllers to the API module
foreach (WebApiControllerRegistration registration in _controllers)
apiModule.RegisterController(registration.ControllerType, (Func<WebApiController>) registration.UntypedFactory);
@@ -177,7 +175,8 @@ namespace Artemis.Core.Services
{
context.Response.ContentType = MimeType.Json;
await using TextWriter writer = context.OpenResponseText();
await writer.WriteAsync(JsonConvert.SerializeObject(data));
string json = JsonConvert.SerializeObject(data, new JsonSerializerSettings {PreserveReferencesHandling = PreserveReferencesHandling.Objects});
await writer.WriteAsync(json);
}
private async Task HandleHttpExceptionJson(IHttpContext context, IHttpException httpException)