Determine if a url matches a Route, and pull out the terms if it does
Posted
by Kevin Montrose
on Stack Overflow
See other posts from Stack Overflow
or by Kevin Montrose
Published on 2010-04-27T02:36:12Z
Indexed on
2010/04/27
2:43 UTC
Read the original article
Hit count: 340
I've got a big old log file I'm trying to break down in terms of routes.
Essentially, I'm getting input of a path (/questions/31415
for example) and a list of all the registered Routes. What I want out is a Route
and the parameters specified in the route (so in, /questions/{id}/{answer}
I'd get id
and answers
out).
I've got a working solution that basically generates a nasty bit of regex on the fly with named groups to do matching and parsing all-in-one. My gut tells me this is a brittle way to do it, and frankly there has to be a better way, right?
© Stack Overflow or respective owner