Skip to content

Instantly share code, notes, and snippets.

@damianh
Last active March 8, 2016 06:41
Show Gist options
  • Save damianh/bf26f8685ecb06a48ede to your computer and use it in GitHub Desktop.
Save damianh/bf26f8685ecb06a48ede to your computer and use it in GitHub Desktop.
Using Nancy with Nowin (without MS.Owin or IAppBuilder).
namespace NancyAndNowin
{
using System;
using System.Net;
using System.Threading.Tasks;
using Nancy.Owin;
using Nowin;
public class Program
{
static void Main(string[] args)
{
var appFunc = NancyMiddleware.UseNancy()(env =>
{
// Optional - use LibOwin for a typed experience around env dictionary.
env["owin.ResponseStatusCode"] = 404;
env["owin.ResponseReasonPhrase"] = "Not found";
return Task.FromResult(0);
});
using(var nowinServer = ServerBuilder.New()
.SetOwinApp(appFunc)
.SetEndPoint(new IPEndPoint(IPAddress.Any, 8080))
.Build())
{
nowinServer.Start();
Console.ReadLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment