Created
January 24, 2014 10:48
-
-
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
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
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