OWIN app.use vs app.run vs app.map [英] OWIN app.use vs app.run vs app.map

查看:164
本文介绍了OWIN app.use vs app.run vs app.map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Owin 中的app.useapp.runapp.map有什么区别? ?什么时候使用什么?阅读文档时并不容易.

解决方案

app.use将中间件插入到管道中,这要求您通过调用next.Invoke()来调用下一个中间件.

app.run插入没有下一个中间件的中间件,因此它可以运行.

使用app.map,您可以映射路径(仅在请求路径与您映射的模式匹配时),以便在运行时针对每个请求进行评估,以运行某些中间件.

请参阅 userun的文档 map 了解更多详细信息

What's the difference among app.use, app.run, app.map in Owin? When to use what? It's not straightforward when reading the documentation.

解决方案

app.use inserts a middleware into the pipeline which requires you to call the next middleware by calling next.Invoke().

app.run inserts a middleware without a next, so it just runs.

With app.map you can map paths, which get evaluated at runtime, per request, to run certain middleware only if the request path matches the pattern you mapped.

See docs for use and run and map for more details

这篇关于OWIN app.use vs app.run vs app.map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆