Last active
November 7, 2019 14:12
-
-
Save gsscoder/5019135 to your computer and use it in GitHub Desktop.
My sample https://github.com/gsscoder/owinhttplistener hosts NancyFx
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 OwinHttpListenerWithNancyFx | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Nancy; | |
using Owin.Listener; | |
public class HelloWorldModule : NancyModule | |
{ | |
public HelloWorldModule() | |
{ | |
Get["/"] = _ => "<a href=\"/hello\">go here</a>"; | |
Get["/hello"] = _ => "Hello, Nancy OWIN!"; | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var nancyOwin = new Nancy.Owin.NancyOwinHost(EmptyApp, new DefaultNancyBootstrapper()); | |
var listener = new OwinHttpListener(nancyOwin.Invoke, new IPAddress(new byte[] { 0, 0, 0, 0 }), 8899); | |
listener.Start(); | |
listener.ListenAsync().Wait(); | |
Console.ReadLine(); | |
listener.Stop(); | |
} | |
static Task EmptyApp(IDictionary<string, object> env) | |
{ | |
var tcs = new TaskCompletionSource<object>(); | |
tcs.SetResult(null); | |
return tcs.Task; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment