Last active
March 8, 2016 06:41
-
-
Save damianh/bf26f8685ecb06a48ede to your computer and use it in GitHub Desktop.
Using Nancy with Nowin (without MS.Owin or IAppBuilder).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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