Created
October 10, 2011 10:15
-
-
Save csainty/1274998 to your computer and use it in GitHub Desktop.
Nancy Demo Blog
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
public class ApiModule : NancyModule | |
{ | |
private readonly IDataStore _Data; | |
public ApiModule(IDataStore data) : base("/api") | |
{ | |
_Data = data; | |
Get["/messages/list"] = p => Response.AsJson(_Data.GetMessages()); | |
Post["/messages/save"] = p => { _Data.AddMessage(Request.Form["Message"]); return "OK!"; }; | |
} | |
} |
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
public class CustomBootstrapper : NinjectNancyBootstrapper | |
{ | |
protected override void InitialiseInternal(IKernel container) | |
{ | |
base.InitialiseInternal(container); | |
container.Bind<IDataStore>().To<InMemoryDataStore>().InSingletonScope(); | |
} | |
} |
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
public class PageModule : NancyModule | |
{ | |
public PageModule() | |
{ | |
Get["/"] = p => View["Default"]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment