I'm learning spray.io, and I'm stuck in a problem.. I'm trying to test the case class extraction of several GET parameters. My code is inspired by the examples from the documentation page :
package com.example
import akka.actor.Actor
import spray.routing._
import spray.http._
import MediaTypes._
class ServiceActor extends Actor
with ServiceHello {
def actorRefFactory = context
def receive = runRoute(testRoute)
trait ServiceHello extends HttpService with Controls {
case class Color(keyword: String, sort_order: Int, sort_key: String)
val route =
path("test") {
parameters('keyword.as[String], 'sort_order.as[Int], 'sort_key.as[String]).as(Color) { color =>
handleTestRoute(color) // route working with the Color instance
}
}
}
This code should be ok, but when I try to run it, I got the following errors :
Cannot resolve symbol as (on top of "as(Color)" )
Missing parameter type: color (on top of "{ color =>")
I understand these errors, but i do not understand why they come...
I'm running Scala 2.10.3
Am I doing something wrong ?
asmethod be called with type parameter? Something likeparameters(...).as[Color]instead ofparameters(...).as(Color)(note the difference in braces)? - Vladimir Matveev