【问题标题】:Anyway to have undertow path template with wildcards无论如何都要有带通配符的路径模板
【发布时间】:2016-04-12 05:20:35
【问题描述】:

我需要处理可能包含许多子路径元素(我可以忽略)的请求,例如以下都将映射到同一个处理程序:

  • /abc?type=a
  • /abc/foo?type=a
  • /abc/foo/bar?type=a

我想出的唯一代码是:

Handlers.pathTemplate().add("/{id}", handler).add("/{id}/foo", handler).add("/{id}/foo/bar", handler);

但这并不理想,因为我需要定义每个可能的路径,无论如何允许(并忽略)我的前缀后的任意数量的路径,例如

Handlers.pathTemplate().add("/{id}*", handler)

Handlers.path().addPrefixPath 允许这种匹配,但我会丢失路径模板变量。

【问题讨论】:

    标签: java undertow


    【解决方案1】:

    我希望您参考这个问题。 Routing template format for undertow

    接受的答案清楚地概述了如何通过 Handlers.routing() 保留路径变量

    【讨论】:

    • 我无法检查,因为我不再使用 Undertow 或无法访问该代码,但它确实看起来可以完成这项工作
    猜你喜欢
    • 2013-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 2011-10-16
    相关资源
    最近更新 更多