1. Click to edit Master title style
• Click to edit Master text styles
– Second level
• Third level
– Fourth level
» Fifth level
ANUG December 2011
20-12-2011 1
2. Agenda
Who Am I?
Super Duper Happy Path
NancyModule
Nancy.Hosting
Nancy.ViewEngines
Nancy.Bootstrapper
Nancy.Authentication
Nancy.Testing
Why use Nancy?
4. Super Duper Happy Path
Lightweight
Write less
Sensible defaults
No non sense
Dynamic
Best effort – very best
Readable!!!!
Testable!!!!
4
5. Super Duper Happy Path
Web
Inventory
Domain Data access
Model
Accounting
5
6. Super Duper Happy Path
Fully composable
Dependency Injection
Easy to isolate
6
7. Super Duper Happy Path
Runs anywhere
Windows
» IIS
» Windows Service
» .exe
Linux + Mono
» ASP.NET
» Kayak
» executables
Azure
AppHarbor
7
8. Click to edit Master title style
• Click to edit Master text styles
– Second level
• Third level
– Fourth level
» Fifth level
Show me the code!
20-12-2011 8
9. Hello World
Click to edit Master title style
• Click to edit Master text styles
– Second level
• Third level
– Fourth level
» Fifth level
20-12-2011 9
10. NancyModule
Where your Nancy experience starts
Organizes your routes
public class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = _ => "Hello from root";
}
}
public class SubModule : NancyModule
{
public SubModule() : base("subpath")
{
Get["/"] = _ => "Hello from subpath";
}
}
11. NancyModule
Defines which verbs you accepts
public class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = _ => "Hello from root";
Post["/”] = _ => DoPost(Request.Form.my_value)
Delete["/{id}”] = p => Delete(p.id);
Put["/”] = _ => …
Patch["/”] = _ => DoPut(Request.my_data)
}
}
12. NancyModule
Allows to setup before and after
public class MainModule : NancyModule
{
public MainModule()
{
Before += context => ... ;
After += context => ... ;
}
}
13. Nancy.Hosting
Your Application
Nancy
Nancy.Hosting
…