asp.net core 5.0,怎么山寨了koa2?

5.0提出了一个中间件的概念。实现思想跟koa一样。

app.Use(async (context, next) =>
        {
            // Do work that doesn't write to the Response.
            await next.Invoke();
            // Do logging or other work that doesn't write to the Response.
        });

        app.Run(async context =>
        {
            await context.Response.WriteAsync("Hello from 2nd delegate.");
        });

  

posted @ 2021-04-20 15:34  猫眼三姐妹  阅读(63)  评论(0编辑  收藏  举报