I am new to spray. I play around with building routes, and while I can get the parameters from the query string using the parameter directive, I am having problems when I want one of the parameters to be a list.
In this example, I defined this case class:
case class Person(name: String, friends: Int)
Currently my route is as follows:
path("test") { get { parameters('name, 'friend ).as(Person) { p => complete(p) } } }
this works fine and i can do get: localhost: 8080 / test? name = jo & friends = 12 and get what I expect.
I want to pass the ids friends list, not just the number of friends, so I started by changing the case class as follows:
case class Person(name: String, friends: Array[Int])
and my call: localhost: 8080 / test? name = jo & friends = 1,2
it does not compile. I get a type mismatch: found: Person.type required: spray.routing.HListDeserializer [formless. :: [String, formless. :: [String, shapeless.HNil]],] get {parameters ('name,' friend). as (Person) {p => ^ comment: this points to P in .as (Person)
Any idea what I'm doing wrong? I would like an answer on how to do this. It would be even better to explain what kind of shapeless type he is looking for. Thanks