Table of Contents

Interface IWebServerService

Namespace
Artemis.Core.Services
Assembly
Artemis.Core.dll

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

PluginsHandler

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

feature PluginFeature
path string

Returns

WebApiControllerRegistration

Type Parameters

T

The 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

feature PluginFeature

The plugin feature the end point is associated with

endPointName string

The name of the end point, must be unique

requestHandler Action<T>

Returns

JsonPluginEndPoint<T>

The resulting end point

Type Parameters

T

The 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

feature PluginFeature

The plugin feature the end point is associated with

endPointName string

The name of the end point, must be unique

requestHandler Func<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

feature PluginFeature

The plugin feature the end point is associated with

endPointName string

The name of the end point, must be unique

requestHandler Func<T, object>

Returns

JsonPluginEndPoint<T>

The resulting end point

Type Parameters

T

The 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

feature PluginFeature

The plugin feature the end point is associated with

endPointName string

The name of the end point, must be unique

requestHandler Func<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

feature PluginFeature

The plugin feature the end point is associated with

endPointName string

The name of the end point, must be unique

requestHandler Action<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

registration WebApiControllerRegistration

The registration of the controller to remove.

RemovePluginEndPoint(PluginEndPoint)

Removes an existing endpoint

void RemovePluginEndPoint(PluginEndPoint endPoint)

Parameters

endPoint PluginEndPoint

The 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

Event Type

EventHandler