Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 134 lines (103 sloc) 6.856 kb
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
1 # Meet Nancy
2
807b5cc @GraemeF Fixed some typos.
GraemeF authored
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.
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
4
5 ## Features
6
807b5cc @GraemeF Fixed some typos.
GraemeF authored
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_
69acffd @thecodejunkie Added Andy Pike and Mindaugas Mozuras to the list of contributors
thecodejunkie authored
8 * Abstracted away from ASP.NET / IIS so that it can run on multiple hosting environments (see below for 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)
4ece39e @thecodejunkie Updated readme.mb to contain information about HEAD requests being suppo...
thecodejunkie authored
9 * Ultra lightweight action declarations for GET, HEAD, PUT, POST and DELETE requests
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
10 * View engine integration (Spark and Razor in development, read below how to help add more to the list)
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
807b5cc @GraemeF Fixed some typos.
GraemeF authored
16 Set up your web.config file:
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
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
807b5cc @GraemeF Fixed some typos.
GraemeF authored
29 Start adding your Nancy modules containing your actions:
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
30
31 public class Module : NancyModule
32 {
9158f86 @thecodejunkie Added module path example to readme file
thecodejunkie authored
33 public Module()
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
34 {
35 Get["/"] = x => {
36 return "This is the root";
37 };
38 }
39 }
40
807b5cc @GraemeF Fixed some typos.
GraemeF authored
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.
0d2e68f @thecodejunkie Added action parameter example to readme file
thecodejunkie authored
42
807b5cc @GraemeF Fixed some typos.
GraemeF authored
43 If you want to get fancy you can add parameters to your paths:
0d2e68f @thecodejunkie Added action parameter example to readme file
thecodejunkie authored
44
45 public class Module : NancyModule
46 {
9158f86 @thecodejunkie Added module path example to readme file
thecodejunkie authored
47 public Module()
0d2e68f @thecodejunkie Added action parameter example to readme file
thecodejunkie authored
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).
9158f86 @thecodejunkie Added module path example to readme file
thecodejunkie authored
56
807b5cc @GraemeF Fixed some typos.
GraemeF authored
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:
9158f86 @thecodejunkie Added module path example to readme file
thecodejunkie authored
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_
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
70
71 ## Help out
72
807b5cc @GraemeF Fixed some typos.
GraemeF authored
73 There are many ways you can contribute to Nancy. Like most open-source software projects, contributing code
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
74 is just one of many outlets where you can help improve. Some of the things that you could help out with in
807b5cc @GraemeF Fixed some typos.
GraemeF authored
75 Nancy are:
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
76
77 * Documentation (both code and features)
78 * Bug reports
79 * Bug fixes
80 * Feature requests
81 * Feature implementations
82 * Test coverage
83 * Code quality
84 * Sample applications
85
86 ## TODO / Design decisions
87
88 1. Make Nancy run on the [Open Web Interface for .NET](http://bvanderveen.com/a/dotnet-http-abstractions "Read more about the Open Web Interface for .NET")
89 2. Enable IoC container integration so that Nancy modules can have dependencies that are resolved at runtime
90 4. Ship a nice set of Response formatters, such as json, xml and others
91 5. Request and Response interception to enable rich middleware capabilities such as caching and logging
92 6. View engine integration. Spark and Razor are planned. Looking for contributors for Haml, NDjango and other popular view engines (contact me if you want to help out!)
93 7. Self-composing framework - make Nancy use an internal IoC to compose the framework at runtime. Increasing modularity of the framework and the ability to swap out parts
94 8. NuGet presence
95
4104ee8 @thecodejunkie Updated readme file with information about view engine integrations
thecodejunkie authored
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.
100
101 * Static - The static view engine serves up any static textfile (which includes html files) you have in your project. It is invoked with the virtual path of the file you want to serve. The
8c5ad0e @thecodejunkie Updated readme file with information about view engine integrations
thecodejunkie authored
102 current implementation serves as a proof of concept and needs more work to be stable
69acffd @thecodejunkie Added Andy Pike and Mindaugas Mozuras to the list of contributors
thecodejunkie authored
103 * [Razor](http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx "Read more about the Razor view engine") - With this view engine you can use views with Nancy. The current implementation serves as a proof of concept and needs more work to be stable
bbbc37b @thecodejunkie Added Robert Greyling to the list of contributors + updated view engines...
thecodejunkie authored
104 * [Spark](http://sparkviewengine.com "Read more about the Spark view engine") - Implemented
69acffd @thecodejunkie Added Andy Pike and Mindaugas Mozuras to the list of contributors
thecodejunkie authored
105 * [NDjango](http://ndjango.org "Read more about the NDjango view engine") - The current implementation serves as a proof of concept and needs more work to be stable
106 * [NHaml](http://code.google.com/p/nhaml "Read more about the NHaml view engine") - The current implementation serves as a proof of concept and needs more work to be stable
8c5ad0e @thecodejunkie Updated readme file with information about view engine integrations
thecodejunkie authored
107 * WebForm - In need of integration help
4104ee8 @thecodejunkie Updated readme file with information about view engine integrations
thecodejunkie authored
108
f485d79 @thecodejunkie Added contributor section to readme file
thecodejunkie authored
109 ## Contributors
110
79557ef @thecodejunkie Integrated contributions by Johan Danforth
thecodejunkie authored
111 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!
8b348e2 @thecodejunkie Updated contributors text in the readme file
thecodejunkie authored
112
69acffd @thecodejunkie Added Andy Pike and Mindaugas Mozuras to the list of contributors
thecodejunkie authored
113 * Andy Pike
f485d79 @thecodejunkie Added contributor section to readme file
thecodejunkie authored
114 * Graeme Foster
ab12c12 @thecodejunkie Added Karl Seguin to the list of contributors
thecodejunkie authored
115 * Karl Seguin
d2f4b80 @thecodejunkie Added Jason Mead into the list of contributors
thecodejunkie authored
116 * Jason Mead
672d2dc @thecodejunkie Added Jeremy Skinner to the list of contributors. Bazinga!
thecodejunkie authored
117 * Jeremy Skinner
7d198d4 @thecodejunkie Updated contributor section of the readme file
thecodejunkie authored
118 * João Bragança
79557ef @thecodejunkie Integrated contributions by Johan Danforth
thecodejunkie authored
119 * Johan Danforth
f485d79 @thecodejunkie Added contributor section to readme file
thecodejunkie authored
120 * John Downey
69acffd @thecodejunkie Added Andy Pike and Mindaugas Mozuras to the list of contributors
thecodejunkie authored
121 * Mindaugas Mozuras
f485d79 @thecodejunkie Added contributor section to readme file
thecodejunkie authored
122 * Pedro Felix
7d198d4 @thecodejunkie Updated contributor section of the readme file
thecodejunkie authored
123 * Phil Haack
bbbc37b @thecodejunkie Added Robert Greyling to the list of contributors + updated view engines...
thecodejunkie authored
124 * Robert Greyling
02273e9 @thecodejunkie Updated readme and added Steven Robbins to list of contributors
thecodejunkie authored
125 * Steven Robbins
e601897 @thecodejunkie Added Vidar L. Somme to list of contributors
thecodejunkie authored
126 * Vidar L. Sømme
8c5ad0e @thecodejunkie Updated readme file with information about view engine integrations
thecodejunkie authored
127
bf81f16 @thecodejunkie Updated readme file to markdown syntax and added contents
thecodejunkie authored
128 ## Copyright
129
130 Copyright © 2010 Andreas Håkansson
131
132 ## License
133
134 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.