-
-
Save amiri/d2d6a38637f585de8782 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package esakkacqrs.HTTP | |
import akka.actor._ | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.server.Directives | |
import akka.stream.ActorMaterializer | |
import akka.util.Timeout | |
import com.typesafe.config.{Config, ConfigFactory} | |
import de.heikoseeberger.akkahttpjson4s.Json4sSupport | |
import esakkacqrs.Command.UserCommandActor | |
import esakkacqrs.Domain.Commands.CreateUser | |
import org.json4s.{jackson, DefaultFormats} | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object API extends App with Json4sSupport { | |
lazy val config = ConfigFactory.load() | |
implicit val system = ActorSystem("api", config) | |
implicit val materializer = ActorMaterializer() | |
implicit val timeout = Timeout(1.second) | |
implicit val commandActor = system.actorOf(Props(classOf[UserCommandActor]), "command-actor"); | |
def route = { | |
import Directives._ | |
import Json4sSupport._ | |
implicit val serialization = jackson.Serialization | |
implicit val formats = DefaultFormats | |
post { | |
path("user") { | |
entity(as[CreateUser]) { user => | |
complete { | |
s"user email is $user" | |
} | |
} | |
} | |
} | |
} | |
Http().bindAndHandle(route, config.getString("app.api.host"), config.getInt("app.api.port")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment