Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Last active November 7, 2019 14:12
Show Gist options
  • Select an option

  • Save gsscoder/4975414 to your computer and use it in GitHub Desktop.

Select an option

Save gsscoder/4975414 to your computer and use it in GitHub Desktop.
Firefly hosting NancyFx
/*
* Install-Package Firefly
* Install-Package Nancy
* Install-Package Nancy.Owin (or just this, will pull the former)
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Firefly.Http;
using Nancy;
using Nancy.Owin;
namespace FireflyHostingNancy
{
public class HelloWorld : NancyModule
{
public HelloWorld()
{
Get["/"] = _ => "Hello world!";
Get["/greet/{someone}"] = paramaters => string.Concat("Greet ", paramaters.SomeOne);
}
}
class Program
{
static void Main(string[] args)
{
NancyOwinHost host = new NancyOwinHost(Empty, new DefaultNancyBootstrapper());
ServerFactory factory = new ServerFactory();
using (factory.Create(host.Invoke, new IPEndPoint(new IPAddress(new byte[] { 0, 0, 0, 0 }), 9900)))
{
Console.WriteLine("press key");
Console.ReadKey();
}
}
static Task Empty(IDictionary<string, object> env)
{
return Task.Factory.StartNew(() => { });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment