librelist archives

« back to archive

Fetching matched pattern in a handler

Fetching matched pattern in a handler

From:
Martin Wernstahl
Date:
2011-04-30 @ 10:34
Hi,

Say, if I have a dynamic pattern to match to a handler, and the handler
itself does not know the pattern beforehand, is there any way of getting the
matched pattern in the handler other than, say, running a regex with
$headers['PATTERN'] on $headers['URL'] ?

Best Regards
    Martin Wernståhl

Re: [mongrel2] Fetching matched pattern in a handler

From:
Zed A. Shaw
Date:
2011-04-30 @ 15:36
On Sat, Apr 30, 2011 at 12:34:48PM +0200, Martin Wernstahl wrote:
> Hi,
> 
> Say, if I have a dynamic pattern to match to a handler, and the handler
> itself does not know the pattern beforehand, is there any way of getting the
> matched pattern in the handler other than, say, running a regex with
> $headers['PATTERN'] on $headers['URL'] ?

Nope, that's how you do it.  I ripped out the pattern collecting code
from the Lua pattern code to speed it up and reduce its overhead.
Instead you just do the matching again if you need it, which fits with
most routing systems anyway.

-- 
Zed A. Shaw
http://zedshaw.com/