Permalink
Browse files

implicit marshalling for future and option types

  • Loading branch information...
1 parent 204188b commit d425a3b0b668f2762ba4cea7ec9e6439445732a0 @fommil fommil committed Oct 25, 2012
@@ -19,24 +19,24 @@ import spray.httpx.marshalling.MetaMarshallers
class CustomerService(implicit val actorSystem: ActorSystem) extends Directives with Marshalling with MetaMarshallers with DefaultTimeout {
def customerActor = actorSystem.actorFor("/user/application/customer")
+ import scala.concurrent.ExecutionContext.Implicits.global
+
val route =
path("customers" / JavaUUID) { id =>
get {
complete {
- import scala.concurrent.ExecutionContext.Implicits.global
(customerActor ? Get(id)).mapTo[Option[Customer]]
}
}
} ~
path("customers") {
get {
- complete{
- val bob = (customerActor ? FindAll()).mapTo[List[Customer]]
- bob
- }
+ complete {
+ (customerActor ? FindAll()).mapTo[List[Customer]]
+ }
} ~
post {
- content(as[RegisterCustomer]) { rc =>
+ entity(as[RegisterCustomer]) { rc =>
complete((customerActor ? rc).mapTo[Either[NotRegisteredCustomer, RegisteredCustomer]])
}
}
@@ -10,15 +10,15 @@ import spray.httpx.marshalling.MetaMarshallers
case class SystemInfo(implementation: Implementation, host: String)
-class HomeService(implicit val actorSystem: ActorSystem) extends Directives with MetaMarshallers with Marshalling with DefaultTimeout {
+class HomeService(implicit val actorSystem: ActorSystem) extends Directives with Marshalling with MetaMarshallers with DefaultTimeout {
def applicationActor = actorSystem.actorFor("/user/application")
val route = {
path(Slash) {
get {
complete {
- import scala.concurrent.ExecutionContext.Implicits.global
+ import scala.concurrent.ExecutionContext.Implicits._
val futureInfo = (applicationActor ? GetImplementation()).mapTo[Implementation].map {
SystemInfo(_, InetAddress.getLocalHost.getCanonicalHostName)
}

0 comments on commit d425a3b

Please sign in to comment.