Last active
November 7, 2019 14:12
-
-
Save gsscoder/4975414 to your computer and use it in GitHub Desktop.
Firefly hosting NancyFx
This file contains hidden or 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
| /* | |
| * 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