Skip to content

Instantly share code, notes, and snippets.

@dborovikov
Created August 24, 2016 10:02
Show Gist options
  • Select an option

  • Save dborovikov/b49620bc0f9f7bf3646d19a301312349 to your computer and use it in GitHub Desktop.

Select an option

Save dborovikov/b49620bc0f9f7bf3646d19a301312349 to your computer and use it in GitHub Desktop.
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.{ ActorMaterializer, Materializer }
import com.typesafe.scalalogging.StrictLogging
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.language.postfixOps
object MicroServer extends App with StrictLogging {
implicit val system: ActorSystem = ActorSystem("micro-server")
implicit val materializer: Materializer = ActorMaterializer()
val route = {
pathSingleSlash {
get {
complete("Done")
}
}
}
try {
val binding = Await.result(Http().bindAndHandle(route, "0.0.0.0", 8089), 10 seconds)
logger.info(s"Bound at $binding")
} catch {
case e: Exception =>
logger.error("Failed to start the server", e)
system.terminate()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment