Posterous theme by Cory Watilo

Filed under: Nancy

Nancy running on Heroku

Last night Ben Hall blogged about how he managed to get Nancy running on Heroku. It’s still an early experiment, and totally unsupported by Heroku itself, but it is very interesting to say the least.

In essence this means that it might be possible to run any Mono compliant (really guys, you need to pay attention to making this the case for your apps, it’s not much work at all) application on Heroku.

Neat!

-

Nancy is a lightweight HTTP framework for building web services and sites. The framework runs on both the .net framework and Mono.

Custom request methods in Nancy

Nancy is a lightweight HTTP framework for building web services and sites. The framework runs on both the .net framework and Mono.

Out of the box, Nancy supports GET, POST, PUT, PATCH, DELETE, OPTIONS and HEAD (although these are a special case of GET requests and handled differently by the framework) requests.

These are the subset of the RFC-2116 that we’ve found useful to support in Nancy. We do understand that your application might have the need to handler different kinds of requests and there are ways around this.

It’s not something we’ve specifically built Nancy to support, but because of the design we use, you can add additional handlers for other types of requests with very little effort.

In the above code I created a custom Nancy module that added a method with the name of the request verb that we want to add support for. The return type of the method is a RouteBuilder, a helper class that is used to provide the syntax Nancy uses for defining route handlers.

Once the module is created, all you have to do to start handling requests of the new method is to inherit your modules from the new base class and add your handlers.

That’s all there is to adding support for additional request methods in Nancy!

A year of the super-duper-happy-path!

”To sum up, I would just kindly advice Andreas to invest his time and enthusiasm into something better, cause this Nancy was definitely born dead."

368 days ago I first announced Nancy on Elegant Code and that was a piece of advice that I received among the many comments that followed.

You know what? Back them he might have been right. Nancy was a personal project that I spiked out in a couple of nights and let loose into the wild with no real expectations.

However, taking a step back an looking at the year that has passed, the complete opposite has unfolded . Since the first commit was made by me, on the 20th of November 2010, quite a lot have changed for Nancy. More than I could have possibly have imagined to be honest.

They grow up so fast

In the announcement post I wrapped up with a list of things I knew I wanted to get into Nancy at that time. Some of them were pretty big tasks, some quite small.

  • A much richer request object
  • The ability to inject dependencies into Nancy modules
  • Conditions on actions
  • View engine integration
  • Ship with a nice bunch of response formatters
  • Self-composed framework
  • Request and Response interception
  • NuGet presence
  • Command line (powershell?) support for spawning up a Nancy application project
  • Provide self-hosting somehow
    Not only did we complete all of the above, but those are just the tip of the ice berg of things that’s happened during the last year. Today Nancy’s matured into an awesome framework for building web sites and services on both .net and Mono.

The list of features that are now supported is too long to list here, but a couple of highlights are support for all the major view engines, inversion of control containers, authentication, request pipelines (both on application and module level), model binding and so much more stuff that it blows my mind.

One thing that pleases me though, is that even with all the added features, Nancy is still a light weight framework because of the way it’s architecture. It’s built with a small core that has some nice extension points built into it. Extensions are built in the form of Nugets and to add a feature you simple grab the Nuget for it and of you go. Right now we have 20 official nugets and a couple of ones that’s been created by the community

Standing on a thousand shoulders

This is not the result of the labor of a single individual, quite the opposite.

Nancy a result of the amazing community that’s evolved around it and the incredible list of 57 people that have contributed over 100 pull requests and of course everybody that’s ever provided feedback, suggestion and that’s blogged, created screencast or talked about Nancy at a conference or other gatherings.

The project is a regular on the GitHub Languages page under the C# page, with 504 watchers and 132 forks at the time when I write this post. If you include the number of people that’s taken part in discussions on our user group and on Twitter.

Thank you so much!

A grumpy fella from the UK

Early one on guy from the UK took Nancy at heart and started contributing some pretty impressive stuff to the project. Right from the start he “got Nancy” and understood the vision I had for the project. It didn’t take long (too long if you ask him) before it was only fair to add him as a core developer and get his name on the mailbox.

I am of course talking about Steven Robbins, a.k.a @grumpydev. Not only has he put a lot of awesome stuff into the project, but he’s also become a good friend over the year that’s passed.

Thanks for all your work on Nancy buddy!

Are we there yet?

Not by a long shot! We’ve got so much stuff planned for the project and there are so many suggestions and contributions coming in every week. However it is important that we pace out self and make sure things does not grown in an uncontrolled rate or direction. Every thing that is added into Nancy is still measured on the same scale as before. Controlled chaos as it’s best!

So here’s hoping for another awesome year!

 

Nancy view cache, now disabled in debug-mode

A quick heads up. In Nancy 0.6.0 we introduced a change that made the application scan, for all available views, and cache them upfront. While this is good for performance, because it reduces view loading time and limits I/O operations, it does pose a slight nuance then you are creating you view.

Because of the cache, each time you made changes to the view template you had to restart the webserver so that the Nancy startup code ran again. A bit of a pain in the sitting area, I agree.

This update is not in the 0.6.0 release it self, not in the NuGet packages. So in order to get a hold of a copy that uses this you will have to either download the latest source code and built it yourself, or grab the latest artifacts from our TeamCity server. 

 

Nancy 0.6.0 saw the light of day

Nancy recently reached version 0.6.0 and was the result of 220 changed files, divided into 126 commits by a total of 12 different authors. That alone is pretty damn awesome if you ask me, but of course we didn’t just make random changes to the code, we did try to add some new cool stuff as well!

The major parts that got some attention in this release were performance, there bootstrapper, the view engines and lots of internal changes that you will only notice if you work with the code.

So let’s dig in an see what we we’ve concocted

Bootstrapper

We are quite proud of the bootstrapping approach we have taken in Nancy. It’s right in the center of everything and helps us implement new functionality with minimal effort but it also helps Nancy users get dependencies into their modules absolutely minimal effort. In the 0.6.0 release we put quite a lot of effort into the bootstrapper code.

Un essence it can be summed up with:

  • A lot cleaner public facing API
  • Makes it easier to implement a custom boostrapper for a different container
  • Reduces friction when adding Nancy functionality moving forwards

View conventions

Prior to 0.6.0 you were pretty limited to where Nancy would look to resolve views to render. In fact you were limited to a folder called views, that had to be in the root of your application. Well that’s now changed into being convention driven instead, with the possibility to modify the conventions yourself.

The default conventions that is shipped with Nancy are

Providing your own is equally as simple. You create a custom boostrapper (that Nancy will find automatically and use) and modify the list (yes, conventions are stored in an IList<Func<string, dynamic, NancyContext>> instance) in what ever way it please you

View caching

Let’s be blunt. View engine were slow in Nancy before we pushed out 0.6.0. Why? Well, for different reasons for different engines, but it all boils down to the fact that views were located and compiled on each and every request. Ya, I know.. slow. But no more! The first thing we did was to have Nancy identify all views that could be rendered (based on the available view engines in your application) and cache them at application startup. This means the file system (or what ever means of storing your views you use) only gets hit once, removing an expensive traversal from the request/response cycle.

The second thing we implemented was a cross-engine view cache. This means that we now cache the compiled, but not initialized, version of a view. Not having to compile the view on each request was huge performance boost. How big you ask? I’ll let you view it with your own eyes.

Benchmark

I know! Pretty impressive, isn’t it. Let me give you some help to understand what you are seeing. The (M) means master branch and (E) means experimental branch. While we were working on this we used a different branch so these benchmarks were taken right before we merged experimental back into master. There’s some fantastic performance improvements across the board, but the one I would like to highlight is the one for string.

This means a route that just returns a simple string. Technically this is not a view, but we used it as a reference point because it’s the simplest form of response. A 28% increase in performance is pure optimization in the request/response life cycle and even then it all came down to some small, clever, changes.

What? You mean the green bar? Oh! That green bar. Well, turn’s out that hitting csc.exe on each request can really kill performance really horrible.

All in all, we are very happy with the changes we made here.

Razor

As if the massive performance boost wasn’t enough we managed to squeeze in some very anticipated features. The two big ones are support for partial views and layouts. We managed to decipher the crypto that is layout support in the razor parser (poor Steve used reflector more than anyone should have to do in a single stretch) so the implementation we provide should be wired up like it is in ASP.NET MVC. There are also some other changes that we have documented on our wiki.

Super-simple view engine

The big changes here are added support for partial views and layouts. This little engine is starting to become quite rich on features but it is still extremely small and embedded into the Nancy dll, so it is accessible when ever you are working on a Nancy application.

Dotliquid

We added a new view engine, this time for the dotliquid markup syntax.

And Bob’s your uncle!

That’s it! It’s not all of it, but that’s the essence of it. We did fix bugs, improve code quality, create more NuGet packages and a lot of small changes as well. So, if you haven’t already, go check it out at nancyfx.org or at the official NuGet feed.

Until next time, happy coding!

Nancy on Hanselminutes and the awesome community behind it

A week ago I was invited to participate in he Hanselminutes postcast by Scott Hanselman to talk about Nancy and Micro Web Framework. The recording for episode #270 can be found at Nancy, Sinatra and the Explosion of .NET Micro Web Frameworks with Andreas Håkansson

I had a great time talking to Scott, who is an excellent host, but one thing I did not get an opportunity to do was to extend my gratitude to the awesome people that are forming up a community around the project, everybody from the people that blog, tweet, screencast or in some other way help Nancy grow into an awesome framework – so thank you to all of you!

The following people have all contributed to the Nancy repository and have helped us get many of the awesome features and bug fixes (if your name should be on this list, but it not, please drop me a line and I will get sorted out!)

Andy Pike, Bjarte Djuvik Næss, Chris Nicola, David Hong, Graeme Foster, Guido Tapia, Hernan Garcia, Ian Davis, Jonas Cannehag, José F. Romaniello, Karl Seguin, Luke Smith, James Eggers, Jason Mead, Jeremy Skinner, João Bragança, Johan Danforth, John Downey, Maciej Kowalewski, Martijn Laarman, Mindaugas Mozûras, Patrik Hägne, Pedro Felix, Piotr Wlodek, Phil Haack, Robert Greyling, Simon Skov Boisen, Steven Robbins, Thomas Pedersen, Troels Thomsen, Vidar L. Sømme

I would like to extend a special thank you and shout out to my friend and co-conspirator Steven Robbins a.k.a @GrumpyDev on Twitter. He is a continuous source of awesome for Nancy and the project is better for having him onboard, that is one thing I am certain on. Thank you buddy!

The Nancy team adds some awesome to the equation

For the past couple of months the number of contributions and modifications to Nancy have really grown in a nice and organic way. During that time it’s started to be a real task to take care of all outstanding work, maintain the community presence, work on documentation and all other things that comes with an open-source project.

For that reason I have decided that the Nancy team needed to expand and there was one candidate that stood out in the crowed. He has contributes more awesome features to Nancy than I can recall, he’s the one person I have an ongoing dialogue with about the progression and vision of the project and I see no better person to gain commit access to the main repository.

I am, of course, talking about the lean mean British “I-code-better-on-beer-and-wine” machine, Steven Robbins a.k.a @grumpydev, author of TinyIoC among things. He also coined the term “super-duper-happy-path” that we use as a guiding star on each new feature we design for Nancy.

Over the next couple of weeks are going to start ironing out all the details for turning the Nancy repository into an organization and moving things out of the core repository, such as the 3rd party dependencies (they will still be around, but not in the main solution).

So, welcome aboard Grumpy and thank you for all your hard and amazing work on Nancy!

 

Getting fancy with Nancy - Introduction

Right from very first day that I announced Nancy to the world, the pace that things have moved forward has been nothing short of amazing. Nancy was always meant to be developed right out there with the community and let me tell you that I have not been disappointed, the community answered the call. Pull request nr. 116 was sent in the other day and over 26 people (with a couple of more having pending requests) have contributed code to Nancy – some of them on multiple occasions.

Since then Nancy has gained an impressive feature lists such as bootstrapping capabilities for all the major Inversion of Control containers, view engine support (spark, razor, ndjango and a Nancy specific engine), hosts for asp.net, WCF, self-hosting and even one of the (if not THE) first OWIN compatible host, cookies, sessions, embedded views, pre- and post-request pipeline, security (authentication and authorization) and many many more. The list keeps on growing.

There have also been several individual and companies that have started writing applications on Nancy, ranging from simple proof of concept applications to actually taking Nancy into a production environment is software that’s sold to customers. We’ve also gotten to see Nancy run on mac and Linux thanks to mono support and we think that’s just awesome!

So what’s the fuzz all about?!

The goal of Nancy is to provide a no fuzz, low ceremony framework for building web applications. One of the key concepts that’s applied when working on Nancy is that everything should have a “super-duper-happy-path” implementation, you shouldn’t have to jump though hops to write your websites there should be a sensible default for everything. Simplicity is key, but not at the expense of power.

At first glance you wouldn’t know it, but pretty much everything in Nancy is customizable. It’s intentionally been designed to stay out of your way, but should you find yourself in need to change a specific behavior Nancy will make it as frictionless as could be.

Right from the get go, Nancy was built to not rely on a specific environment to be able to run. We built the concept of host adapters and they site right in between Nancy and what ever environment she might run on. Out of the box we currently supply hosts for running on top of ASP.NET, WCF, OWIN and a self-host (built on httplistner), but the list is sure to expand and writing adapters is easy.

There is no dependency, what so ever, on System.Web from the Nancy core assembly so you can, without any problem, embed Nancy in your applications and so on. ReST-based end-point in your application? Sure why not?!

Bla, bla, bla – show me the codez!

Alrighty then. To give you an idea of how it is to work with Nancy, we will be building a simple Hello World (surprise!) Nancy web application. The application will be built to run on ASP.NET, but it could just as easily have been running on any of the others hosts (just swap it out, no code changes needed).

To get started create a new ASP.NET Empty Web Application project (don’t worry, we have our own project template but let’s skip those and get right to the fun stuff). Once you’ve created the application it’s time to grab Nancy. You could visit out repository to download the source and build the binaries, or you could choose the easy way; use NuGet to grab the bits we need.

We are going to go with the NuGet packages, so grab the Nancy.Hosting.Aspnet nuget. Not only will this install the adapter required to run Nancy on ASP.NET, but it will also register the adapter in your web.config and grab the Nancy core nuget.

That’s it. You have the foundation of a Nancy application running on top of ASP.NET. Now you need contents. So let’s add a module to our project (modules can be added anywhere in your project, Nancy will find them for you).

What you are looking at is a module that responds to a GET request to the root path of your application. When an incoming requests matches those criterion, Nancy will respond with the text “Hello World”. Run the application and verify that I’m not kidding you – it really is as simple as that!

That’s all will show you in this post. In following posts I will be sure to take you on a journey in the world of Nancy and show you things like POST, PUT, DELETE and HEAD requests, injecting dependencies into modules, using response formatters, grabbing parameters from the requested route, complex route syntax, view engines, model binding, before/after request handling (both on request and module level) and much, much more.

Nancy on the web.

If you want to talk about Nancy you can find us on Google Groups or on Twitter using the #NancyFx hashtag. You can also reach me on twitter @thecodejunkie

Nancy, the little community-powered framework that could

Two months ago, on the day, I first announced Nancy here on Elegant Code as my new open-source project. I could never have anticipated the chain of events that would take place during the following two months. My tweet about the blog post got re-tweeted more times than I can remember and the post filled up with, mostly, awesome feedback.

It took about and week and then Nancy got the first pull request on her github account and from there it started to build up momentum quite fast. At the time of this writing there’s been 53 pull requests, by about 20 different people, for all kinds of features, bug fixes, custom hosts… you name it. Not bad, eh?

Not only that, but Nancy has managed to pull together a nice little community, over at Google Groups, where the future of Nancy is being discussed every day. She’s also getting some attention on Twitter and we’re trying to gather it all under the #NancyFx hashtag and seems like every day there is a new face popping up.

In the initial commit there were a couple of abstractions and light extension points in place for things like custom hosts, view engines and response formatters. These turned out to be a very smart move, because the community really embraced and ran with them. Let me recap some of the things that has happened since day zero

  • View engines; there are currently support for Spark, Razor, NDjango and Static templates. We did have support for NHaml for a while, but that community seems to have gone into hibernation, so the decision was made to pull it and not waste dev cycles on it until there was a demand
  • Inversion of Control integration; this has been one of the big one. Right from the very first beginning I wanted Nancy to be a self composing framework, that is have a small internal container that glued the framework together at runtime. I also wanted the possibility to register module level dependencies. It took a while and a couple of iterations, but we finally settled on a design and made TinyIoC the internal container. It was very important that it was a transparent experience to the end user and unless you have a need for it, you never know it’s there. Not only that, but thanks to community contributions we’ve managed to create hooks (known as bootstrappers in Nancy) for all of the major players such as StructureMap, Autofac, Unity, Ninject and Windsor. Using one of these container with Nancy is a very easy thing to do and only adds one more file to your project
  • Response formatters; one of the powerful features in Nancy is the response model and how it lets you return different kinds of things and leverages implicit cast operators to hide the complexity behind it. Thanks to the awesome Nancy community we now have the capability to return JSON, XML, images and perform redirect responses. It’s super easy to write a response extension and hook it into Nancy, so if you have any ideas….
  • Bug fixes; yeah I know, it’s shocking, but it’s still true. Every now and then someone finds a bug but, more importantly, most of the time the same person is part of contributing a patch to resolve it!
  • Hosts; Nancy has been designed with the idea of being able to run in multiple environments and shipped with a host to run on top of ASP.NET. Right now we have additional hosts for running Nancy on a WCF host and on a stand alone host. There are more of them on the way
  • HEAD requests; the first release of Nancy supported GET, POST, PUT and DELETE requests, but thanks to a clever little contributions she now also serves up HEAD requests
  • Cookies; not he ones you can eat….
  • Cookie based sessions; I think this is also self describing.. oh… yeah they are encrypted in case you were wondering!
  • Mono; we’ve started to seriously look at getting Nancy to run on top of the up coming mono 2.10 release (we need the improvements they’ve made to the dynamic keyword) and have already managed to run the sample application on both Linux and Mac OSX. Moving forward mono is going to be a supported and equally priorities platform to support
  • Visual Studio templates; these are still work in progress but right now I have the ability to new up a new Nancy project, based on the html5boilerplate … and we have a bare bone template in the making
  • Buildscript; a couple of days a go we added what every self respecting open-source project needs; a build script. We choose to use Rake (that’s a ruby powered format, for those of you that’s never seen it before) and make use of the excellent Albacore gem, but the awesome Derick Bailey

I’ve probably forgotten a bunch of things, there’s been so much going on that I can’t remember it all without looking at the commit history! That said, there are still things we want to put in place and there are already extensive discussions on the user group about them

  • Security
  • Content negotiation
  • OWIN hosting (we’re keeping track of the OWIN 1.0 specification)
  • Self-hosting (Benjamin van der Veen, if you are reading this – maybe Kayak can be a candidate!)

The one thing that we can’t seem to pull of

Is to find a designer to design a proper logo for the framework! We are in desperate need to get an awesome logo that we can put everywhere and start creating a website. So if you know any good designers that wouldn’t mind putting in some time in designing an awesome logo for an open-source project (read pro bono) and please tell them about us and about Nancy! A while back I created a post about the Nancy logo on our user group. It contains some information on the philosophy and goals for a logo for Nancy. I can’t stress enough how much I would appreciate if you took this and shared it with your designer friends!

As always, if you want to ping me either drop me a comment right here on the blog or find me on on Twitter account @TheCodeJunkie

… I can’t help to wonder what Nancy will be like in another two months!

Introducing Nancy, a lightweight web framework inspired by Sinatra

For a couple of weeks I have been keeping myself busy with open-source stuff. One of the things has been to spike out a web framework idea and later on turn it into a real project. The project is inspired, but not a clone, by the Sinatra web framework built on Ruby. The name, Nancy, is a reference to Nancy Sinatra, the daughter of Frank Sinatra.

There are quite of lot of things that I want to put into the framework, but it is functional in its current state. One of the goals for Nancy is to make it run on other environment and platforms, other than ASP.NET / IIS and there are spikes taking place to run it on Mono with FastCGI, making it possible to run on a bunch of other platforms. However, although this is the goal, the current source code does not provide any helpers to make that possible. Right now it only ships with an IHttpHandler that acts as an adaptor between ASP.NET / IIS and the Nancy engine.

The project is built using C# and makes use of xUnit, MSpec and FakeItEasy

The key component in a Nancy application is the modules. This is where you create actions, which are handlers for a given request type at a given path. Let me show you what I mean

public class Module : NancyModule{    public Module()    {        Get["/"] = parameters => {            return "This is the site route";        };        Delete["/product/{id}"] = parameters => {            return string.Concat("You requested that the following product should be deleted: ", parameters.id);        };    }}

What you are looking at here is the foundation of a very small application that will responde to GET requests to the root URL of the site, and DELETE requests to /products/{id} where {id} is a parameter placeholder. All parameters will be captured and injected into the action, like you see with parameters.id.The entire route handling mechanism is swappable, so you could write your own handler that were able to interpreted the route syntax that you prefer. A module can also be declared with a module path, meaning that all action routes, that you declare in the module, will be relative the module path.

For example if you were to do

public class Module : NancyModule{    public Module() : base("/foo")    {        Get["/"] = parameters => {            return "This is the site route";        };        Delete["/product/{id}"] = parameters => {            return string.Concat("You requested that the following product should be deleted: ", parameters.id);        };    }}

The the application would respond to requests sent to /foo and /foo/product/{id}. You can of course have as many modules as you want. Nancy will detect them all and figure out which action that should be invoked. There are also some nice ticks in there for return values. In the examples above you get the impression that you are expected to return a string, and this is not the case. In fact each action returns an instance of a Response type. What you are seeing is the result of some implicit cast operators. There are a couple of them declared

public class Module : NancyModule{    public Module()    {        Get["/"] = parameters => {            return "Returning a string";        };        Get["/404"] = parameters => {            return 404;        };        Get["/500"] = parameters => {            return HttpStatusCode.NotFound;        };    }}

All of these will work and send back a valid HttpResponse (including headers) to the client. You can of course explicitly return a Response instance which opens up for some nice customization. A module in Nancy also declares a pair of properties called View and Response. Both of these have an interface return type and each of them are empty marker interfaces that you can use to wire up extension methods. The View property is meant to be used for view engine integration and in an unpublished spike (still needs some more work) I’ve wired up the http://www.sparkviewengine.com/ so that Nancy is able to process spark files. This is an example of what that looks like

public class SparkModule : NancyModule{    public SparkModule()    {        Get["/user/{name}"] = parameters => {            return View.Spark("user.spark", parameters);        };    }}

Of course all of this is work in progress and the syntax might change. The goal is to support all of the popular view engines and if you are up to the task of implementing support for one of those, please let me know – I would love the help!

The Response property is meant to be used for extensions that help format the response in different ways. A test I have running locally is an extension method that enables me to return json formatted data.

public class JsonModule : NancyModule{    public JsonModule()    {        Get["/user/{name}"] = parameters => {            return Response.AsJson(someObject);        };    }}

Of course I would like for Nancy to ship with a healthy set of these response helpers, so feel free to chip in!

Oh, there is one last property that you can use and that is the Request property which gives you access to the current request information, so that you can use it from inside of your action handlers. Right now it is limited to the requested path and verb, but the goal is to have a rich representation of the current request – what stuff would you like to see in it?

public class RequestModule : NancyModule{    public RequestModule()    {        Get["/"] = parameters => {            return string.Format("You requested {0}", Request.Path);        };    }}

One thing I would like to mention about the action handlers and their routes. If there are two or more routes that are a match to the current request, Nancy is going to select the one that has the most matching static path segments before a parameter placeholder is reached (but all segment has to be filled!). What does this mean? Take the following routes

/foo/{value}/foo/bar/{value}

The first route has one static path segment (/foo) and the second one has two (/foo/bar). So for a request to

/foo/bar

The first route will be selected, but for

/foo/bar/baz

the second route will be selected. It also important to understand that in Nancy, all path parameters are greedy, not like in ASP.NET MVC where you can have one greedy (indicated by a star *) and has to be at the end. If you define a route

/foo/{value1}/bar/{value2}you can invoke it with

/foo/this/is/some/segments/bar/and/then/some/more

and you will end up with

{value1} = /this/is/some/segments{value2} = /and/then/some/more

Of course, like I said before, this is how the default route handler works and if you don’t like it you can write your own, all you have to do is implement a single interface and tell Nancy to use it.

So before I end this post, let me tell you about some of the things that are planned to be included in Nancy as soon as possible


  • A much richer request object. Nancy uses it’s own Request object and is not tied down the the one found in ASP.NET. I want to support a rich and easy to use model for request information. If you have any suggestions on the structure of this object, please let me know
  • The ability to inject dependencies into Nancy modules. I want you to be able to wire up Nancy to use your favorite IoC and have Nancy resolve constructor dependencies of Nancy modules
  • Conditions on actions. I want to add an optional predicate on actions like Get[“/foo”, () => somePredicate], to give Nancy the ability to select actionsat runtime. For example you might have two identical actions define, but you add a predicate on one of them that made sure that it was only selected if the client was a mobile device. Actions that has a predicate defines should have higher priority than those that do not
  • View engine integration. Like I said, the Nancy modules comes with the View property, which is of the type IViewEngine, where you can hook up view engine support. All you need is an adapter that returns a string (or a Response instance). Please let me know if you want to chip in and help wire up one or more view engines
  • Ship with a nice bunch of response formatters. These are created by attaching extension methods to the IResponseFormatter interface, which is the property type of the Response property on a Nancy module. I think the formatters should follow a naming convention where you name them As<something>
  • Self-composed framework. What is mean with this is that I want to build Nancy on top of a tiny, internal, IoC that is used to compose the framework at runtime. It should be exposed in a simple way so that you could swap out components (such as the route matcher, or module discovery mechanism) as you please
  • Request and Response interception. The idea is to provide a lightweight way to intercept Nancy requests before they hit the Nancy application and let you either pass the request to the Nancy application or prematurely send back a reply. Combines with the ability to intercept Responses sent by the Nancy application, it should give a nice way of extending Nancy with features like logging and caching. You can think of this as a sort of IHttpModule mechanism
  • NuGet presence
  • Command line (powershell?) support for spawning up a Nancy application project
  • Provide self-hosting somehow

There are a bunch of other stuff I have in my head, but I have to give them some more thought to distil proper ideas from them. But please, let me know if you can think of anything more! I want to keep Nancy lightweight and easy to use, so it will probably never be as open-ended as ASP.NET MVC, FubuMVC or Manos de Mano – but we’ll have to wait and see!

You can find the source code at my Nancy repository at GitHub. You can also reach me on Twitter at @TheCodeJunkie. If you want to talk about Nancy drop me a line in the comments or on Twitter and we can move onto e-mail, gtalk, skype or messenger if needed! I hope you like where Nancy is going!