Giter Club home page Giter Club logo

nancy's Introduction

Meet Nancy

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.

Features

  • 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
  • Abstracted away from ASP.NET / IIS so that it can run on multiple hosting environments (planned OWIN support), such as (but not limited to) ASP.NET, WCF, Mono/FastCGI and more (ASP.NET and WCF currently supported out-of-the-box)
  • Ultra lightweight action declarations for GET, HEAD, PUT, POST and DELETE requests
  • View engine integration
  • Powerful request path matching that includes advanced parameter capabilities. The path matching strategy can be replaced with custom implementations to fit your exact needs
  • Easy response syntax, enabling you to return things like int, string, HttpStatusCode and Action elements without having to explicitly cast or wrap your response - you just return it and Nancy will do the work for you

Usage

Set up your web.config file:

<httpHandlers>
    <add verb="*" type="Nancy.Hosting.NancyHttpRequestHandler" path="*"/>
</httpHandlers>

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
        <add name="Nancy" verb="*" type="Nancy.Hosting.NancyHttpRequestHandler" path="*"/>
    </handlers>
</system.webServer>

Start adding your Nancy modules containing your actions:

public class Module : NancyModule
{
    public Module()
    {
        Get["/"] = x => {
            return "This is the root";
        };
    }
}

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.

If you want to get fancy you can add parameters to your paths:

public class Module : NancyModule
{
    public Module()
    {
        Get["/greet/{name}"] = x => {
            return string.Concat("Hello ", x.name);
        };
    }
}

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 over at my blog on [ElegantCode](http://elegantcode.com "Visit ElegantCode).

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:

public class Module : NancyModule
{
    public Module() : base("/butler")
    {
        Get["/greet/{name}"] = x => {
            return string.Concat("Hello ", x.name);
        };
    }
}

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

Bootstrappers

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 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.

Community

You can find lot of Nancy users on the Nancy User Group. That is where most of the discussions regarding the development and usage of Nancy is taking place. You can also find Nancy on Twitter using the #NancyFx hashtag.

Help out

There are many ways you can contribute to Nancy. Like most open-source software projects, contributing code is just one of many outlets where you can help improve. Some of the things that you could help out with in Nancy are:

  • Documentation (both code and features)
  • Bug reports
  • Bug fixes
  • Feature requests
  • Feature implementations
  • Test coverage
  • Code quality
  • Sample applications

View Engines

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 of integration work to get it running in Nancy. Currently there are support for Razor, Spark, NDjango and a static file engine. There used to be an NHaml 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!

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!

Contributors

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!

Copyright

Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors

License

Nancy is licensed under MIT. Refer to license.txt for more information.

nancy's People

Contributors

andypike avatar gatapia avatar graemef avatar grumpydev avatar haacked avatar hongymagic avatar jasonmead avatar jeremyskinner avatar jfromaniello avatar jtdowney avatar lukesmith avatar mazur avatar mmozuras avatar pmhsfelix avatar robertthegrey avatar ssboisen avatar thecodejunkie avatar thedersen avatar thefringeninja avatar tt avatar vidarls avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.