Created
August 24, 2016 10:02
-
-
Save dborovikov/b49620bc0f9f7bf3646d19a301312349 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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