Nancy 是属于 .Net 基金会的一个项目,本文将简要介绍该项目相关的信息。
中文介绍内容翻译自英文介绍,主要采用意译、如与原文存在出入,请以原文为准。
Nancy 是一个轻量的,简洁的HTTP服务构建框架,能够支持运行于 .Net Framework/Core 以及 Mono。该框架的目标在保持平台无关的前提下,保持各个环节都拥有 super-duper-happy-path 的体验(极致畅爽的开发体验)。
Nancy 能够处理 DELETE
, GET
, HEAD
, OPTIONS
, POST
, PUT
和 PATCH
的请求。
其提供了一套简明优雅的 DSL 以便开发者能够稍微敲打几个字便能处理 HTTP 响应。这样开发者便可以将更多的时间应用于业务代码与核心程序。
以下便是一个简明扼要的 Hello 代码实例:
public class Module : NancyModule
{
public Module()
{
Get("/greet/{name}", x => {
return string.Concat("Hello ", x.name);
});
}
}
“super-duper-happy-path” (或称 SDHP) 是我们为体现 Nancy 框架的核心精神和创建的短语,并且我们秉承着 “super-duper-happy-path” 的经验,在 API 开发中努力践行。
尽管很难具体的定义这种精神是什么,毕竟这是一个非常情绪化的术语,不过其基本的奥义如下:
Above all, creating an application with Nancy should be a pleasure, and hopefully fun! But without sacrificing the power or extensibility that you may need as your application grows.
综上所述,采用 Nancy 构建一个应用程序将会是一件令人愉悦的乐事,完全不需要牺牲功能性和扩展性,轻松构建您的应用程序。
在 .Net 中构建 HTTP 应用程序的传统方法皆是围绕微软传统框架: WebForms 、 MVC 、 WebAPI 等等。而 Nancy 作为一个独立的开源项目已经存在很长时间,并且一直在活跃中。
如果您正想查找一个轻量型优秀 HTTP 应用程序构建框架,这回事一个不错的尝试。
Nancy is a lightweight, low-ceremony, framework for building HTTP based services on .NET Framework/Core and Mono. The goal of the framework is to stay out of the way as much as possible and provide a super-duper-happy-path to all interactions.
Nancy is designed to handle DELETE
, GET
, HEAD
, OPTIONS
, POST
, PUT
and PATCH
requests and provides a simple, elegant, Domain Specific Language (DSL) for returning a response with just a couple of keystrokes, leaving you with more time to focus on the important bits..
your code and your application.
Write your application
public class Module : NancyModule
{
public Module()
{
Get("/greet/{name}", x => {
return string.Concat("Hello ", x.name);
});
}
}
The “super-duper-happy-path” (or SDHP if you’re ‘down with the kids’ ;-)) is a phrase we coined to describe the ethos of Nancy; and providing the “super-duper-happy-path” experience is something we strive for in all of our APIs.
While it’s hard to pin down exactly what it is, it’s a very emotive term after all, but the basic ideas behind it are:
Above all, creating an application with Nancy should be a pleasure, and hopefully fun! But without sacrificing the power or extensibility that you may need as your application grows.
以上《英文介绍》摘录自 .NET Foundation 的项目介绍 。原文受原项目许可证保护。