Skip to content

Instantly share code, notes, and snippets.

@neuecc
Last active January 2, 2016 04:59
Show Gist options
  • Save neuecc/8254249 to your computer and use it in GitHub Desktop.
Save neuecc/8254249 to your computer and use it in GitHub Desktop.
Koa / Owin
using Microsoft.Owin.Hosting;
using Owin;
using System;
namespace ConsoleApplication43
{
class Program
{
static void Main(string[] args)
{
using (WebApp.Start<Startup>("http://localhost:12345"))
{
Console.ReadLine();
}
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
// KoaとOwinを比較して
// http://blog.kazupon.jp/post/71041135220/koa
// 3. Response Middleware
app.Use(async (context, next) =>
{
Console.WriteLine(">> one");
await next();
Console.WriteLine("<< one");
});
app.Use(async (context, next) =>
{
Console.WriteLine(">> two");
await context.Response.WriteAsync("two");
await next();
Console.WriteLine("<< two");
});
app.Use(async (context, next) =>
{
Console.WriteLine(">> three");
await next();
Console.WriteLine("<< three");
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment