Skip to content

Commit

Permalink
implicit marshalling for future and option types
Browse files Browse the repository at this point in the history
  • Loading branch information
fommil committed Oct 25, 2012
1 parent 204188b commit d425a3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d425a3b

Please sign in to comment.