using System; using System.Threading.Tasks; using GenHTTP.Api.Infrastructure; using GenHTTP.Api.Protocol; namespace Artemis.Core.Services; /// /// A service that provides access to the local Artemis web server /// public interface IWebServerService : IArtemisService { /// /// Gets the current instance of the web server, replaced when occurs. /// IServer? Server { get; } /// /// Gets the plugins module containing all plugin end points /// PluginsHandler PluginsHandler { get; } /// /// Adds a new endpoint for the given plugin feature receiving an object of type /// Note: Object will be deserialized using JSON. /// /// The type of object to be received /// The plugin feature the end point is associated with /// The name of the end point, must be unique /// /// The resulting end point JsonPluginEndPoint AddJsonEndPoint(PluginFeature feature, string endPointName, Action requestHandler); /// /// Adds a new endpoint for the given plugin feature receiving an object of type and /// returning any . /// Note: Both will be deserialized and serialized respectively using JSON. /// /// The type of object to be received /// The plugin feature the end point is associated with /// The name of the end point, must be unique /// /// The resulting end point JsonPluginEndPoint AddResponsiveJsonEndPoint(PluginFeature feature, string endPointName, Func requestHandler); /// /// Adds a new endpoint for the given plugin feature receiving an a . /// /// The plugin feature the end point is associated with /// The name of the end point, must be unique /// /// The resulting end point StringPluginEndPoint AddStringEndPoint(PluginFeature feature, string endPointName, Action requestHandler); /// /// Adds a new endpoint for the given plugin feature receiving an a and returning a /// or . /// /// The plugin feature the end point is associated with /// The name of the end point, must be unique /// /// The resulting end point StringPluginEndPoint AddResponsiveStringEndPoint(PluginFeature feature, string endPointName, Func requestHandler); /// /// Adds a new endpoint for the given plugin feature that handles a raw . /// /// Note: This requires that you reference the EmbedIO /// Nuget package. /// /// /// The plugin feature the end point is associated with /// The name of the end point, must be unique /// /// The resulting end point RawPluginEndPoint AddRawEndPoint(PluginFeature feature, string endPointName, Func> requestHandler); /// /// Removes an existing endpoint /// /// The end point to remove void RemovePluginEndPoint(PluginEndPoint endPoint); /// /// Adds a new Web API controller and restarts the web server /// /// The type of Web API controller to add WebApiControllerRegistration AddController(PluginFeature feature, string path) where T : class; /// /// Removes an existing Web API controller and restarts the web server /// /// The registration of the controller to remove. void RemoveController(WebApiControllerRegistration registration); /// /// Occurs when the web server has been created and is about to start. This is the ideal place to add your own modules. /// event EventHandler? WebServerStarting; }