Created
February 24, 2016 19:37
-
-
Save christiansparre/85b51e9a4ffc798d8b10 to your computer and use it in GitHub Desktop.
NancyFX vs Web API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Web.Http; | |
| using Microsoft.Owin.Hosting; | |
| using Nancy; | |
| using Owin; | |
| namespace ConsoleApplication4 | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| string nancyAddress = "http://localhost:8000/"; | |
| string webApiAddress = "http://localhost:9000/"; | |
| WebApp.Start<StartupNancy>(url: nancyAddress); | |
| WebApp.Start<StartupWebApi>(url: webApiAddress); | |
| Console.ReadLine(); | |
| } | |
| } | |
| public class StartupNancy | |
| { | |
| public void Configuration(IAppBuilder appBuilder) | |
| { | |
| appBuilder.UseNancy(); | |
| } | |
| } | |
| public class StartupWebApi | |
| { | |
| public void Configuration(IAppBuilder appBuilder) | |
| { | |
| HttpConfiguration config = new HttpConfiguration(); | |
| config.Routes.MapHttpRoute( | |
| name: "DefaultApi", | |
| routeTemplate: "", | |
| defaults: new { controller = "Home", action = "Hello" } | |
| ); | |
| appBuilder.UseWebApi(config); | |
| } | |
| } | |
| public class Module : NancyModule | |
| { | |
| public Module() | |
| { | |
| Get["/"] = o => "Hello from NancyFx"; | |
| } | |
| } | |
| public class HomeController : ApiController | |
| { | |
| [HttpGet] | |
| public string Hello() | |
| { | |
| return "Hello from Web API"; | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my machine:
NancyFx gets around 6500 req/s
WebApi gets around 30000 req/s