Created
March 2, 2014 06:12
-
-
Save aodag/9302663 to your computer and use it in GitHub Desktop.
OwinContextなしで、KatanaのStartupを利用
This file contains 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.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Threading.Tasks; | |
using System.IO; | |
using System.Text; | |
namespace OwinSample | |
{ | |
public class HelloApp | |
{ | |
string message; | |
public HelloApp(object next, string message) | |
{ | |
this.message = message; | |
} | |
public Task Invoke(IDictionary<string, object> env) | |
{ | |
var headers = env["owin.ResponseHeaders"] as IDictionary<string, string[]>; | |
headers["Content-type"] = new string[]{"text/plain;charset=utf-8"}; | |
var contents = Encoding.UTF8.GetBytes(message); | |
var body = env["owin.ResponseBody"] as Stream; | |
return body.WriteAsync(contents, 0, contents.Length); | |
} | |
} | |
} |
This file contains 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.Threading.Tasks; | |
using Microsoft.Owin; | |
using Owin; | |
[assembly: OwinStartup(typeof(OwinSample.Startup))] | |
namespace OwinSample | |
{ | |
public class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
app.Use<HelloApp>("Hello, world!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment