通常在 OpenRasta 中有这样的配置:
ResourceSpace.Has.ResourcesOfType<Customers>()
.AtUri("/customers/region/{region}")
... // and so on
... 其中路径的 {region}
部分自动映射到处理方法中的字符串参数。因此,如果用户点击:
http://server/customers/region/emea
然后向处理程序方法传递字符串“emea”。
除了这样做,我还想用这样的东西注册一个处理程序:
ResourceSpace.Has.ResourcesOfType<Customers>()
.AtUri("/someotherthing/*")
... // and so on
在这个假想的语法中,星号表示“将路径的其余部分(包括斜杠)作为单个字符串参数传递给处理方法”。因此,如果用户点击:
http://server/someotherthing/how/about/this?that=other
然后我的处理程序方法接收一个字符串参数:
how/about/this?that=other
在 OpenRasta 中这样的事情可能吗?
在 Sinatra (Ruby) 中,我会使用正则表达式来完成此操作。
更新:到目前为止,我的猜测是自定义管道以某种方式修改路径以伪装斜杠...
最佳答案
trac 上有一个补丁可以将此功能添加到 RC 分支。
我将在本周末将这些更改作为 RC2 推送,因此您将获得通配符语法。
请注意,它看起来像/{name:*}
关于openrasta - 在 OpenRasta 中,如何配置一个 URI,其中我将 "the remainder of the path"作为单个字符串获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2699765/