问题
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