Skip to content
Newer
Older
100644 152 lines (118 sloc) 7.7 KB
65237cd @grumpydev Updated contributors.
grumpydev authored
1 # Meet Nancy
2
3 Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aims to deliver a low ceremony approach to building light, fast web applications.
4
5 ## Features
6
7 * Built from the bottom up, not simply a DSL on top of an existing framework. Removing limitations and feature hacks of an underlying framework, as well as the need to reference more assemblies than you need. _keep it light_
8 * Abstracted away from ASP.NET / IIS so that it can run on multiple hosting environments (planned [OWIN](http://bvanderveen.com/a/dotnet-http-abstractions "Read more about the Open Web Interface for .NET") support), such as (but not limited to) ASP.NET, WCF, Mono/FastCGI and more (ASP.NET and WCF currently supported out-of-the-box)
9 * Ultra lightweight action declarations for GET, HEAD, PUT, POST and DELETE requests
10 * View engine integration
11 * Powerful request path matching that includes advanced parameter capabilities. The path matching strategy can be replaced with custom implementations to fit your exact needs
12 * Easy response syntax, enabling you to return things like int, string, HttpStatusCode and Action<Stream> elements without having to explicitly cast or wrap your response - you just return it and Nancy _will_ do the work for you
13
14 ## Usage
15
16 Set up your web.config file:
17
18 <httpHandlers>
19 <add verb="*" type="Nancy.Hosting.NancyHttpRequestHandler" path="*"/>
20 </httpHandlers>
21
22 <system.webServer>
23 <validation validateIntegratedModeConfiguration="false"/>
24 <handlers>
25 <add name="Nancy" verb="*" type="Nancy.Hosting.NancyHttpRequestHandler" path="*"/>
26 </handlers>
27 </system.webServer>
28
29 Start adding your Nancy modules containing your actions:
30
31 public class Module : NancyModule
32 {
33 public Module()
34 {
35 Get["/"] = x => {
36 return "This is the root";
37 };
38 }
39 }
40
41 Start your application and enjoy! Swap out Get with either Put, Post or Delete to create actions that will respond to calls using those request methods.
42
43 If you want to get fancy you can add parameters to your paths:
44
45 public class Module : NancyModule
46 {
47 public Module()
48 {
49 Get["/greet/{name}"] = x => {
50 return string.Concat("Hello ", x.name);
51 };
52 }
53 }
54
55 The _{name}_ parameter will be captured and injected into the action parameters, shown as _x_ in the sample. The parameters are represented by a _dynamic_ type so you can access any parameter name straight on it as a property or an indexer. For more information on action parameters please refer to the [Nancy introduction post](http://elegantcode.com/2010/11/28/introducing-nancy-a-lightweight-web-framework-inspired-by-sinatra "Read the Nancy introduction post at elegantcode.com") over at my blog on [ElegantCode](http://elegantcode.com "Visit ElegantCode).
56
57 Nancy also supports the idea of _module paths_, where you assign a root path for all actions in the module and they will all be relative to that:
58
59 public class Module : NancyModule
60 {
61 public Module() : base("/butler")
62 {
63 Get["/greet/{name}"] = x => {
64 return string.Concat("Hello ", x.name);
65 };
66 }
67 }
68
69 Notice the _base("/butler")_ call to the NancyModule constructor. Now all action paths that are defined in the module will be relative to _/butler_ so in order to greet someone you could access _/butler/greet/{name}_, for example _/butler/greet/thecodejunkie_
70
71 ## Bootstrappers
72
73 The bootstrapper projects for third party IoC containers are only temporarily in the source code. These will be removed when the IoC integration design has been proven stable. They will be moving into a contrib-style project and/or the Nancy wiki. The reason they
74 won't ship with Nancy is because we do not want to be tasked each time there is a new version of the containers released.
75
76 ## Community
77
78 You can find lot of Nancy users on the [Nancy User Group](https://groups.google.com/forum/?fromgroups#forum/nancy-web-framework). That is where most of the discussions regarding the development and usage of Nancy is taking place. You can also
79 find Nancy on Twitter using the #NancyFx hashtag.
80
81 ## Help out
82
83 There are many ways you can contribute to Nancy. Like most open-source software projects, contributing code
84 is just one of many outlets where you can help improve. Some of the things that you could help out with in
85 Nancy are:
86
87 * Documentation (both code and features)
88 * Bug reports
89 * Bug fixes
90 * Feature requests
91 * Feature implementations
92 * Test coverage
93 * Code quality
94 * Sample applications
95
96 ## View Engines
97
98 There is a rich set of view engines in the .net space and most of them have been design in such a away that they are framework agnostic, all that is needed is a bit
99 of integration work to get it running in Nancy. Currently there are support for [Razor](http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx "Read more about the Razor view engine"),
100 [Spark](http://sparkviewengine.com "Read more about the Spark view engine"), [NDjango](http://ndjango.org "Read more about the NDjango view engine") and a static file engine. There used to be an [NHaml](http://code.google.com/p/nhaml "Read more about the NHaml view engine")
101 engine but it was removed since the view engine project appears to have come to a dead halt. Let us know if that change! WebForms engine.. well let's just say that if you have a need to use WebForms with Nancy then _we accept patches_!
102
103 All view engine integrations are still very early implementations and more work will be put towards them to bring as many of the features, as possible, into Nancy! If you have any experience with either of the engines, grab a fork and start coding!
104
105 ## Contributors
106
107 Nancy is not a one man project and many of the features that are availble would not have been possible without the awesome contributions from the community!
108
109 * [Andy Pike](http://github.com/andypike)
110 * [Bjarte Djuvik Næss](http://github.com/bjartn)
111 * [Carlo Kok](http://github.com/carlokok)
112 * [Chris Nicola](http://github.com/lucisferre)
113 * [David Hong](http://github.com/davidhong)
114 * [Graeme Foster](http://github.com/GraemeF)
115 * [Guido Tapia](http://github.com/gatapia)
116 * [Ian Davis](http://github.com/innovatian)
117 * [Jonas Cannehag](http://github.com/knecke)
118 * [José F. Romaniello](http://github.com/jfromaniello)
119 * [Karl Seguin](http://github.com/karlseguin)
120 * [Leo Duran](http://github.com/leoduran)
121 * [Luke Smith](http://github.com/lukesmith)
122 * [James Eggers](http://github.com/jameseggers1)
123 * [Jason Mead](http://github.com/meadiagenic)
124 * [Jeremy Skinner](http://github.com/jeremyskinner)
125 * [João Bragança](http://github.com/thefringeninja)
126 * [Johan Danforth](http://github.com/johandanforth)
127 * [Johan Nilsson](http://github.com/Dashue)
128 * [John Downey](http://github.com/jtdowney)
129 * [Mark Rendle](http://github.com/markrendle)
130 * [Maciej Kowalewski](http://github.com/maciejk)
131 * [Mindaugas Mozûras](http://github.com/mmozuras)
132 * [Patrik Hägne](http://github.com/patrik-hagne)
133 * [Pedro Felix](http://github.com/pmhsfelix)
134 * [Piotr Wlodek](http://github.com/pwlodek)
135 * [Phil Haack](http://github.com/haacked)
136 * [Robert Greyling](http://github.com/robertthegrey)
137 * [Roy Jacobs](http://github.com/RoyJacobs)
138 * [Simon Skov Boisen](http://github.com/ssboisen)
139 * [Steven Robbins](http://github.com/grumpydev)
140 * [Thomas Pedersen](http://github.com/thedersen)
141 * [Troels Thomsen](http://github.com/troethom)
142 * [Vidar L. Sømme](http://github.com/vidarls)
143 * [NeqO](https://github.com/NeqO)
144
145 ## Copyright
146
147 Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors
148
149 ## License
150
151 Nancy is licensed under [MIT](http://www.opensource.org/licenses/mit-license.php "Read more about the MIT license form"). Refer to license.txt for more information.
Something went wrong with that request. Please try again.