/* * Copyright (C) 2009-2014 Typesafe Inc. */ package akka.http.scaladsl.server import akka.http.scaladsl.marshallers.xml.ScalaXmlSupport import akka.http.scaladsl.server.directives.Credentials import akka.stream.scaladsl._ import com.typesafe.config.{ ConfigFactory, Config } import akka.actor.ActorSystem import akka.stream.ActorMaterializer import akka.http.scaladsl.Http object TestServer extends App { val testConf: Config = ConfigFactory.parseString(""" akka.loglevel = INFO akka.log-dead-letters = off""") implicit val system = ActorSystem("ServerTest", testConf) import system.dispatcher implicit val materializer = ActorMaterializer() import ScalaXmlSupport._ import Directives._ def auth: AuthenticatorPF[String] = { case p @ Credentials.Provided(name) if p.verify(name + "-password") ⇒ name } val bindingFuture = Http().bindAndHandle({ get { path("") { complete(index) } ~ path("secure") { authenticateBasicPF("My very secure site", auth) { user ⇒ complete(Hello { user }. Access has been granted!) } } ~ path("ping") { complete("PONG!") } ~ path("crash") { complete(sys.error("BOOM!")) } } ~ pathPrefix("inner")(getFromResourceDirectory("someDir")) }, interface = "localhost", port = 8080) println(s"Server online at http://localhost:8080/\nPress RETURN to stop...") Console.readLine() bindingFuture.flatMap(_.unbind()).onComplete(_ ⇒ system.shutdown()) lazy val index =

Say hello to akka-http-core!

Defined resources:

}