I'm new to spray. Im playing around with building the routes, and while I manage to get parameters out of the query string using the parameters directive, I'm having trouble when I want one of the parameters to be a list.
For this example I've defined this case class:
case class Person(name: String, friends: Int)
my route currently looks like this:
path("test") {
get { parameters('name, 'friend ).as(Person) { p => complete(p) } }
}
this works fine and I can do a get: localhost:8080/test?name=jo&friends=12 and get what I expect.
I want to pass a list of friends ids, rather than just the number of friends, so I started by changing my case class like so:
case class Person(name: String, friends: Array[Int])
and my call to: localhost:8080/test?name=jo&friends=1,2
this does not compile. I get a type mismatch: found : Person.type required: spray.routing.HListDeserializer[shapeless.::[String,shapeless.::[String,shapeless.HNil]],?] get { parameters('name, 'friend ).as(Person) { p => ^ comment: this points at the P in .as(Person)
Any idea on what I'm doing wrong? I'd love an answer on how to do it. Even better would be an explanation to what is this shapeless type that it's looking for. Thanks