Windows Service hosting HTTP based services using Nancy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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

记录平时瞎折腾遇到的各种问题, 方便查找
使用 Hugo 构建
主题 Stack 3.29.0Jimmy 设计