.NET的微型Web框架 Nancy
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);
};
}
}
本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!