Skip to content

Instantly share code, notes, and snippets.

@thecodejunkie
Created January 24, 2014 10:48
Show Gist options
  • Save thecodejunkie/8595308 to your computer and use it in GitHub Desktop.
Save thecodejunkie/8595308 to your computer and use it in GitHub Desktop.
Simple sample that shows how to replace the route handler lambda with a function + using constructor dependencies from the module
using Nancy;
public class IndexModule : NancyModule
{
private readonly IFoo foo;
public IndexModule(IFoo foo)
{
this.foo = foo;
Get["/"] = DoSomething;
}
private dynamic DoSomething(dynamic parameters)
{
return foo.GetMessage();
}
}
public interface IFoo
{
string GetMessage();
}
public class DefaultFoo : IFoo
{
public string GetMessage()
{
return "Hello world";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment