수색…


소개

카타나 란 무엇입니까? Katana는 Microsoft Open Technologies Group이 관리하는 OWIN 기반 웹 응용 프로그램을 구축하고 호스팅하기위한 오픈 소스 구성 요소 집합입니다. Katana는 OWIN 사양을 구현하며 실제로 많은 수의 ASP.NET 프로젝트 템플릿에 사용됩니다 . 또한 Katana는 다양한 준비가 가능한 미들웨어 구성 요소를 제공하며 OWIN 기반 응용 프로그램에서 사용할 수 있습니다.

기본 KatanaConsole 응용 프로그램

namespace KatanaConsole
{
    // use an alias for the OWIN AppFunc:
    using AppFunc = Func<IDictionary<string, object>, Task>;
 
    class Program
    {
        static void Main(string[] args)
        {
            WebApp.Start<Startup>("http://localhost:8080");
            Console.WriteLine("Server Started; Press enter to Quit");
            Console.ReadLine();
        }
    }
 
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var middleware = new Func<AppFunc, AppFunc>(MyMiddleWare);
            app.Use(middleware);
        }
 
        public AppFunc MyMiddleWare(AppFunc next)
        {
            AppFunc appFunc = async (IDictionary<string, object> environment) =>
            {
                // Do something with the incoming request:
                var response = environment["owin.ResponseBody"] as Stream;
                using (var writer = new StreamWriter(response))
                {
                    await writer.WriteAsync("<h1>Hello from My First Middleware</h1>");
                }
                // Call the next Middleware in the chain:
                await next.Invoke(environment);
            };
            return appFunc;
        }
    }
}


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow