1

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/

jony
  • 119
  • 3
  • 13
  • 1
    If you need to know which one matched you need two different endpoints, the or makes it implicit that you don't care which one of the two you just matched. – Ende Neu Jun 10 '16 at 15:08
  • Hmm.. Can't we do any thing with regex? Thinking of implementing a Set using regex and get output? – jony Jun 10 '16 at 16:27

0 Answers0