I'm new to Akka. While learning I've created a sample project on Github. Here this project uses Akka
, Akka-HTTP
, Slick
, Flyway
and Macwire
. I wanted to implement Akka Actors for HTTP routing. I tried to implement this on redis/
but not working as expected.
Currently the Controller
is working as:
class AuthController(userService: UserService[Future]) extends Controller {
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
implicit val serialization: Serialization.type = jackson.Serialization // or native.Serialization
implicit val formats: DefaultFormats.type = DefaultFormats
override def route: Route = pathPrefix("users") {
pathEndOrSingleSlash {
register
}
}
private def register = {
(post & entity(as[RegistrationData])) { registrationData =>
complete(userService.registerUser(registrationData))
}
}
}
But I'm trying to implement something like this with some changes in existing code:
class AuthController(userhandler: ActorRef) extends Controller {
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
implicit val serialization: Serialization.type = jackson.Serialization // or native.Serialization
implicit val formats: DefaultFormats.type = DefaultFormats
override def route: Route = pathPrefix("users") {
pathEndOrSingleSlash {
register
}
}
private def register = {
(post & entity(as[RegistrationData])) { registrationData =>
complete(
(userHandler ? UserHandler.Register(registrationData)).map {
case true => OK -> s"Thank you ${registrationData.username}"
case _ => InternalServerError -> "Failed to complete your request. please try later"
}
)
}
}
}
Can anyone suggest me how can I implement the above? I appreciate your help.