Interface IWebServerService
A service that provides access to the local Artemis web server
public interface IWebServerService
Properties
PluginsHandler
Gets the plugins module containing all plugin end points
PluginsHandler PluginsHandler { get; }
Property Value
Server
Gets the current instance of the web server, replaced when WebServerStarting occurs.
IServer? Server { get; }
Property Value
- IServer
Methods
AddController<T>(PluginFeature, string)
Adds a new Web API controller and restarts the web server
WebApiControllerRegistration AddController<T>(PluginFeature feature, string path) where T : class
Parameters
featurePluginFeaturepathstring
Returns
Type Parameters
TThe type of Web API controller to add
AddJsonEndPoint<T>(PluginFeature, string, Action<T>)
Adds a new endpoint for the given plugin feature receiving an object of type T
Note: Object will be deserialized using JSON.
JsonPluginEndPoint<T> AddJsonEndPoint<T>(PluginFeature feature, string endPointName, Action<T> requestHandler)
Parameters
featurePluginFeatureThe plugin feature the end point is associated with
endPointNamestringThe name of the end point, must be unique
requestHandlerAction<T>
Returns
- JsonPluginEndPoint<T>
The resulting end point
Type Parameters
TThe type of object to be received
AddRawEndPoint(PluginFeature, string, Func<IRequest, Task<IResponse>>)
Adds a new endpoint for the given plugin feature that handles a raw IHttpContext.
Note: This requires that you reference the EmbedIO Nuget package.
RawPluginEndPoint AddRawEndPoint(PluginFeature feature, string endPointName, Func<IRequest, Task<IResponse>> requestHandler)
Parameters
featurePluginFeatureThe plugin feature the end point is associated with
endPointNamestringThe name of the end point, must be unique
requestHandlerFunc<IRequest, Task<IResponse>>
Returns
- RawPluginEndPoint
The resulting end point
AddResponsiveJsonEndPoint<T>(PluginFeature, string, Func<T, object?>)
Adds a new endpoint for the given plugin feature receiving an object of type T and
returning any object.
Note: Both will be deserialized and serialized respectively using JSON.
JsonPluginEndPoint<T> AddResponsiveJsonEndPoint<T>(PluginFeature feature, string endPointName, Func<T, object?> requestHandler)
Parameters
featurePluginFeatureThe plugin feature the end point is associated with
endPointNamestringThe name of the end point, must be unique
requestHandlerFunc<T, object>
Returns
- JsonPluginEndPoint<T>
The resulting end point
Type Parameters
TThe type of object to be received
AddResponsiveStringEndPoint(PluginFeature, string, Func<string, string?>)
Adds a new endpoint for the given plugin feature receiving an a string and returning a string or null.
StringPluginEndPoint AddResponsiveStringEndPoint(PluginFeature feature, string endPointName, Func<string, string?> requestHandler)
Parameters
featurePluginFeatureThe plugin feature the end point is associated with
endPointNamestringThe name of the end point, must be unique
requestHandlerFunc<string, string>
Returns
- StringPluginEndPoint
The resulting end point
AddStringEndPoint(PluginFeature, string, Action<string>)
Adds a new endpoint for the given plugin feature receiving an a string.
StringPluginEndPoint AddStringEndPoint(PluginFeature feature, string endPointName, Action<string> requestHandler)
Parameters
featurePluginFeatureThe plugin feature the end point is associated with
endPointNamestringThe name of the end point, must be unique
requestHandlerAction<string>
Returns
- StringPluginEndPoint
The resulting end point
RemoveController(WebApiControllerRegistration)
Removes an existing Web API controller and restarts the web server
void RemoveController(WebApiControllerRegistration registration)
Parameters
registrationWebApiControllerRegistrationThe registration of the controller to remove.
RemovePluginEndPoint(PluginEndPoint)
Removes an existing endpoint
void RemovePluginEndPoint(PluginEndPoint endPoint)
Parameters
endPointPluginEndPointThe end point to remove
Events
WebServerStarting
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