Skip to content

Commit

Permalink
= routing: change internal behaviour of host with regex function
Browse files Browse the repository at this point in the history
  • Loading branch information
bthuillier committed Jan 14, 2014
1 parent 4123138 commit 9b8ebbf
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ trait HostDirectives {
*/
def host(regex: Regex): Directive1[String] = {
def forFunc(regexMatch: String Option[String]): Directive1[String] = {
hostName.map(regexMatch).flatMap {
case Some(matched) provide(matched)
case None reject
hostName.flatMap { name
regexMatch(name) match {
case Some(matched) provide(matched)
case None reject
}
}
}

regex.groupCount match {
case 0 forFunc(regex.findPrefixOf(_))
case 1 forFunc(regex.findPrefixMatchOf(_).map(_.group(1)))
Expand Down

0 comments on commit 9b8ebbf

Please sign in to comment.