Created
November 28, 2009 07:24
-
-
Save beatty/244429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A RouteInfo generated by a RegexRoute. We hold the matcher that was used to verify the match | |
* so that we can capture the groups. We also lug along the paramNames list. We lazily evaluate | |
* param names as this is probably cheaper/faster than building a map of names->values up front. | |
*/ | |
class RegexRouteInfo(val matcher: Matcher, val paramNames: List[String]) extends RouteInfo { | |
def param(name: String): String = { | |
val idx = paramNames.findIndexOf(_ == name) | |
if (idx > -1 && idx < matcher.groupCount) matcher.group(idx + 1) else throw new IllegalArgumentException("bad paramName: " + name) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment