Spray routing - matched path value

144 views Asked by At

We can use Pipe(|) for path matching in Spray for the use case of "OR" like below.

val route =
 path("foo" | "bar" ) {
  complete(??)
}

From above example, how to know the value originally it matched (From "foo" or "bar". Which one? ). I didn't find any method giving this. We can solve this by using a Map and it gives the value. Without using "Map", can i get matched string.

val route =
  path(Map("foo"->"foo", "bar"->"bar" )) { mathcedString => 
   complete(matchedString)
  }
}

http://spray.io/documentation/1.2.2/spray-routing/path-directives/path/

0

There are 0 answers