Nancy 是属于 .Net 基金会的一个项目,本文将简要介绍该项目相关的信息。
中文介绍
中文介绍内容翻译自英文介绍,主要采用意译、如与原文存在出入,请以原文为准。
Nancy
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 |
The super-duper-happy-path (极致畅爽的开发体验)
“super-duper-happy-path” (或称 SDHP) 是我们为体现 Nancy 框架的核心精神和创建的短语,并且我们秉承着 “super-duper-happy-path” 的经验,在 API 开发中努力践行。
尽管很难具体的定义这种精神是什么,毕竟这是一个非常情绪化的术语,不过其基本的奥义如下:
- “It just works”(轻松启动) - 开发者可以轻松的用起来,而无需要将复杂的内容混合在一起。想要添加一个新的模块?好的,没问题!它将会被自动发现并弃用;想要引入一个新的视图引擎?好的,没问题!所有的工作都已经准备好了您无需过多操心;想要为模块注入一个新的依赖项?好的,没问题!默认我们将会为您定位并注入它到您的模块,完全零配置。
- “Easily customisable”(快乐扩展) - 尽管已经能够轻松启动,但是如果需要进行自定义扩展也不应有任何障碍。比如想要自定义依赖注入容器?完全没问题!想要调整路由规则?完全没问题!通过框架的启动器机制,所有这些自定义都是小菜一碟。
- “Low ceremony”(极致简洁) - 在您的程序中为了框架而写的 “Nancy 代码” 尽可能被保持最小。使用 Nancy 构建的应用程序中最为重要的部分应该是您的代码。我们的代码为您服务,为您编写精妙的应用程序而让路。您甚至完全可以在一篇推文(140个字符)中将你应用程序所需要编写的 Nancy 代码全部包含其中。
- “Low friction”(纵享丝滑) - 使用 Nancy 构建应用程序,我们将助您成功而非制造麻烦。尽管命名需要明确,配置量也被最小化,但其拥有的功能性和扩展性并不会打折,依旧强力,如您所需。
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 构建一个应用程序将会是一件令人愉悦的乐事,完全不需要牺牲功能性和扩展性,轻松构建您的应用程序。
Project Details
- 官方网站
- 项目源码
- 项目许可证: MIT
- NuGet
- 项目联系人: Andreas Håkansson & Steven Robbins
相关链接
笔者简评
在 .Net 中构建 HTTP 应用程序的传统方法皆是围绕微软传统框架: WebForms 、 MVC 、 WebAPI 等等。而 Nancy 作为一个独立的开源项目已经存在很长时间,并且一直在活跃中。
如果您正想查找一个轻量型优秀 HTTP 应用程序构建框架,这回事一个不错的尝试。
英文介绍
Nancy
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 |
The super-duper-happy-path
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:
- “It just works” - you should be able to pick things up and use them without any mucking about. Added a new module? That’s automatically discovered for you. Brought in a new View Engine? All wired up and ready to go without you having to do anything else. Even if you add a new dependency to your module, by default we’ll locate that and inject it for you - no configuration required.
- “Easily customisable” - even though “it just works”, there shouldn’t be any barriers that get in the way of customisation should you want to work the way you want to work with the components that you want to use. Want to use another container? No problem! Want to tweak the way routes are selected? Go ahead! Through our bootstrapper approach all of these things should be a piece of cake.
- “Low ceremony” - the amount of “Nancy code” you should need in your application should be minimal. The important part of any Nancy application is your code - our code should get out of your way and let you get on with building awesome applications. As a testament to this it’s actually possible to fit a functional Nancy application into a single Tweet :-)
- “Low friction” - when building software with Nancy the APIs should help you get where you want to go, rather than getting in your way. Naming should be obvious, required configuration should be minimal, but power and extensibility should still be there when you need it.
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.
Project Details
- Website
- Source
- License: MIT
- NuGet
- Project Lead: Andreas Håkansson & Steven Robbins
Quicklinks
以上《英文介绍》摘录自 .NET Foundation 的项目介绍 。原文受原项目许可证保护。
其他项目地址
- Akka.NET - 【Actor开发框架】
- AngleSharp - 【浏览器引擎】
- ASP.NET SignalR - 【Web实时通信框架】
- ASP.NET MVC, Web API and Web Pages Razor - 【Web开发框架】
- ASP.NET Ajax Control Toolkit - 【Ajax开发工具】
- ASP.NET Core - 【新时代Web开发框架】
- AutoMapper - 【对象映射管理】
- Microsoft Azure SDK for .NET - 【SDK】
- Microsoft Azure WebJobs SDK - 【SDK】
- BenchmarkDotNet - 【基准测试框架】
- Cake - 【本地自动化框架】
- Chemistry Add-in for Word - 【Word插件】
- Couchbase Lite for .NET - 【NoSQL引擎】
- DNN Platform - 【CMS系统】
- .NET Compiler Platform Roslyn - 【编译器】
- .NET Micro Framework - 【嵌入式框架】
- .NET SDK For Hadoop - 【SDK】
- DotVVM: Component-based MVVM framework for ASP.NET - 【Web服务端MVVM框架】
- Entity Framework - 【ORM】
- Humanizer - 【工具库】
- IdentityManager - 【身份认证数据管理工具】
- IdentityModel - 【身份认证对接库】
- IdentityServer - 【OAuth服务端】
- SixLabors.ImageSharp - 【2D绘图库】
- DLR/IronPython2/IronPython3 - 【.Net上运行Python】
- Json.NET - 【JSON处理库】
- Kudu - 【自动化框架】
- LLILC - 【语言底层项目】
- MailKit - 【邮件处理工具库】
- Managed Extensibility Framework MEF, MEF2 - 【模块化工具库】
- Microsoft Web Protection Library - 【Web防攻击工具库】
- MimeKit - 【MIME处理工具库】
- ML.NET - 【机器学习框架】
- Cecil - 【语言底层项目】
- Mono - 【语言跨平台底层项目】
- MSBuild - 【本地自动化框架】
- MVVM Light Toolkit - 【客户端MVVM开发框架】
- MvvmCross - 【客户端MVVM开发框架】
- Nancy - 【Web开发框架】
- .NET Core - 【Web开发框架】
- Newtonsoft.Json - 【JSON处理库】
- NuGet - 【包管理框架】
- NUnit Test Framework - 【单元测试框架】
- Open Live Writer - 【博客协作工具】
- Open XML SDK - 【Office SDK】
- Orchard CMS - 【CMS系统】
- Orleans - 【Actor开发框架】
- OWIN Authentication Middleware Katana Project - 【Web开发框架】
- Peachpie Compiler Platform - 【.Net上运行PHP】
- Polly - 【服务调用工具库】
- Prism - 【客户端MVVM开发框架】
- Protobuild - 【项目文件生成工具】
- Reactive Extensions for .NET - 【反应式编程框架】
- ReactiveUI - 【反应式编程UI框架】
- Salesforce Toolkits for .NET - 【SDK】
- SourceLink - 【源码调试支持】
- Steeltoe - 【微服务框架】
- System.Drawing Mono - 【2D绘图工具库】
- Telerik UI for UWP - 【UWP UI框架】
- Umbraco - 【CMS框架】
- UWP Community Toolkit - 【UWP 工具库】
- WCF - 【跨进程通信框架】
- Windows Phone Toolkit - 【WP 工具库】
- Windows Template Studio - 【UWP 项目模板】
- Windows Forms - 【客户端开发框架】
- WiX Toolset - 【安装包制作框架】
- WorldWide Telescope - 【宇宙探索工具】
- Windows Presentation Foundation WPF - 【客户端开发框架】
- Xamarin.Auth - 【移动端身份认证工具库】
- Xamarin.Mobile - 【移动端工具库】
- xUnit.net - 【单元测试框架】