Advertisement
amironov73

NancyFX sample

Dec 24th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. using Nancy;
  4. using Nancy.Hosting.Self;
  5.  
  6. public class StructuredHello
  7. {
  8.     public string Message { get; set; }
  9.  
  10.     public string For { get; set; }
  11. }
  12.  
  13. public class HelloModule : NancyModule
  14. {
  15.     public static StructuredHello _Hello
  16.         = new StructuredHello
  17.           {
  18.               Message = "Hello",
  19.               For = "You"
  20.           };
  21.  
  22.     public HelloModule()
  23.     {
  24.         Get["/"] = parameters => Response.AsJson(_Hello);
  25.     }
  26. }
  27.  
  28. class Program
  29. {
  30.     static void Main()
  31.     {
  32.         Uri uri = new Uri("http://localhost:1234");
  33.  
  34.         using (NancyHost host = new NancyHost(uri))
  35.         {
  36.             host.Start();
  37.             Console.WriteLine("Running on {0}", uri);
  38.             Console.ReadLine();
  39.         }
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement