.NET的微型Web框架 Nancy

fmms 13年前

Nancy 是一个轻量级用于构建基于 HTTP 的 Web 服务,基于 .NET 和 Mono 平台。

Nancy 设计用于处理 DELETE, GET, HEAD, OPTIONS, POST, PUT 和 PATCH 等请求方法,并提供简单优雅的 DSL 以返回响应。它具有以下特性:

  • 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
  • Run anywhere. Nancy is not built on any specific hosting technology can can be run anywhere. Out of the box, Nancy supports running on ASP.NET/IIS, WCF, Self-hosting and any OWIN
  • Ultra lightweight action declarations for GET, HEAD, PUT, POST, DELETE, OPTIONS and PATCH requests
  • View engine integration (Razor, Spark, NDjango, dotLiquid and our own SuperSimpleViewEngine)
  • 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
  • A powerful, light-weight, testing framework to help you verify the behavior of your application

示例代码:

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

项目主页:http://www.open-open.com/lib/view/home/1333591279749