Skip to content

Instantly share code, notes, and snippets.

@adamw
Created May 4, 2019 12:41
Show Gist options
  • Save adamw/c35b89a8cc4bdce41daffcdb703bbf78 to your computer and use it in GitHub Desktop.
Save adamw/c35b89a8cc4bdce41daffcdb703bbf78 to your computer and use it in GitHub Desktop.
def startServer(): Unit = {
import scala.concurrent.Await
import scala.concurrent.duration._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.Http
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
val routes: Route = getBooksRoute ~ getBookCoverRoute ~ addBookRoute
implicit val actorSystem: ActorSystem = ActorSystem()
implicit val materializer: ActorMaterializer = ActorMaterializer()
Await.result(Http().bindAndHandle(routes, "localhost", 8080), 1.minute)
println("Server started!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment