天天看点

7 款仿照 Sinatra 思路的 .NET 框架

Martin 基于映射 URL 到 Action 的思路,支持 GET, POST, PUT, DELETE 操作。

Manos 是一个易用、易于测试、高性能的 .NET 的 Web 框架。

示例代码:

Route ("/timeout", ctx => {

    ctx.Response.WriteLine ("Hello");

    AddTimeout (TimeSpan.FromSeconds (2), (app, data) => {

        Console.WriteLine ("writing world.");

        ctx.Response.WriteLine ("World");

        ctx.Response.End ();

    });

});

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

Nancy 设计用于处理 <code>DELETE</code>, <code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>, <code>POST</code>, <code>PUT</code> <code>和 PATCH</code> 等请求方法,并提供简单优雅的 DSL 以返回响应。