In OpenRasta, how do I configure a URI where I get “the remainder of the path” as a single string?

霸气de小男生 提交于 2019-12-10 20:44:46

问题


Normally in OpenRasta there is some configuration like this:

ResourceSpace.Has.ResourcesOfType<Customers>()
    .AtUri("/customers/region/{region}")
    ... // and so on

... where the {region} part of the path is automatically mapped to a string parameter in the handling method. So if the user hits:

http://server/customers/region/emea

Then the handler method is passed the string "emea".

As well as doing this, I'd like to register a handler with something like this:

ResourceSpace.Has.ResourcesOfType<Customers>()
    .AtUri("/someotherthing/*")
    ... // and so on

In this imaginary syntax, the asterisk would mean "take the rest of the path, including slashes, to be a single string parameter to pass to the handling method". And so if the user hits:

http://server/someotherthing/how/about/this?that=other

Then my handler method receives a string parameter:

how/about/this?that=other

Is such a thing possible in OpenRasta?

In Sinatra (Ruby) I'd use a regular expression to do exactly this.

Update: My guess so far is a custom pipeline that munges the path to disguise the slashes somehow...


回答1:


There's a patch on trac to add this functionality to the RC branch.

I'll be pushing those changes as an RC2 this weekend, so you'll get the wildcard syntax.

Note that it's going to look like /{name:*}



来源:https://stackoverflow.com/questions/2699765/in-openrasta-how-do-i-configure-a-uri-where-i-get-the-remainder-of-the-path-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!