最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vert.x - Practical differences between single and multiple routes? - Stack Overflow

programmeradmin5浏览0评论

Does it make a difference if I create multiple routes with no matching criteria vs a single route?

E.g.

            router.route().handler(BodyHandler.create())
            router.route().handler(ResponseContentTypeHandler.create())

vs.

with(router.route()){
            handler(BodyHandler.create())
            handler(ResponseContentTypeHandler.create())
}

One difference I did notice is that the priority is enforced within the route, but not across the routes. So e.g. this will pass


            router.route().handler(Handler<RoutingContext>{ .. })
            router.route().handler(AutenticationHandler{ .. })

but this will fail:

with(router.route()){
            handler(Handler<RoutingContext>{ .. })
            handler(AutenticationHandler{ .. })
}

Per the javadoc:

You should add multiple handlers to the same route object rather than creating two different routes objects with one handler for route

but what is the worst thing that would happen if I create different routes?

发布评论

评论列表(0)

  1. 暂无评论