I'm trying to figure out what the handler url is in the handler class or to be more precise add is added to the handler url. When I add a handler I create a mapping, for example:
/ping --> PingWebHandler
If I use IWebRequest:PathInfo then the /ping part is included as well. But I'm interested in what is *added* to /ping, since within the Handler I cannot make any assumptions about what the "mount point" is.
Well, not entirely. I'm trying to make a generic WebHandler which can mounted to any handler url. So /ping can be /foo or /foor/bar or whatever. Let's say I want to create a RestWebHandler. Inside the webhandler I want to be able to program something for /customer of /order of /customer/order. But since I have only the IWebRequest:PathInfo I don't know upfront if the RestWebHandler is mounted with /rest or /rest/web or /foor/bar. Imho, the handler url part shouldn't be in the PathInfo property (or there should another property).
There is a default web handler in the mapping file. Change that to be your class and all requests will come to your web handler. I am not sure if you will need to edit the mapping file or if you can do that through PDSOE.
So to clarify a bit more, inside the webhandler I want program something like:
when "/customer" then ...
when "/order" then ...
Now, how do I get requestPath? The only info I have is (afaik) PathInfo, but this includes the handler url part as well. What do I do if I don't want to force anyone to use a specific handler url?
Here's the deal. I make the following call:
This last one because I said the /ping is handled by my PingWebHandler class. But I can say that /foo is handled by my PingWebHandler as well. In that case the PathInfo would be /foo/bla/bla2. To make things generic I'm not interesting in either the /ping of /foo part (this can be anything since it's a configuration thing), but in the /bla/bla2 part.
edit: rewrote the URL because a link was made out of it.
In such cases where different URL's goes to same method, I generally use this code
poRequest:URI:TOSTRING () matches "*<stringname*"
based on the condition, I call a method that would do appropriate action by passing the poRequest to that method
That would be a solution, albeit an error prone one.
I think it would have been better solution if there was another property (in IWebRequest) called HandlerUrl en that the HandlerUrl part was *not* in PathInfo. A bit like express in node.js works. This way it would have been much easier to make generic code.
This last one because I said the /ping is handled by my PingWebHandler class. But I can say that /foo is handled by my PingWebHandler as well. In that case the PathInfo would be /foo/bla/bla2.
To make things generic I'm not interesting in either the /ping of /foo part (this can be anything since it's a configuration thing), but in the /bla/bla2 part.
Thanks Peter, I will submit an enhancement request.
Answer to the original question: it is possible via workarounds, but not generically (yet). At least one workaround below in this thread.
EDIT: Mike Banks came up with the solution for my question. Above statement is no longer true.
Yes! This is exactly what I'm looking for!
request:GetContextValue("URI_FINAL_MATCH_GROUP") is the correct answer. Thanks.
is this documented anywhere?