
Windows Service hosting HTTP based services using Nancy
public partial class SaturnAPIService : ServiceBase
{
NancyHost host;
public SaturnAPIService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
//necessary because of Namespace Reservations
var config = new HostConfiguration() { RewriteLocalhost = true, UrlReservations = new UrlReservations() { CreateAutomatically = true } };
host = new NancyHost(config, new Uri("http://localhost:1234"));
host.Start();
}
protected override void OnStop()
{
host.Stop();
}
refer to > https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy