Skip to content

Instantly share code, notes, and snippets.

@zergood
Created May 27, 2015 11:26
Show Gist options
  • Save zergood/53977efd500985a34ea1 to your computer and use it in GitHub Desktop.
Save zergood/53977efd500985a34ea1 to your computer and use it in GitHub Desktop.
Akka http sample for benchmarking
trait Core {
implicit val system: ActorSystem = ActorSystem("Suggestion")
implicit val materializer: ActorFlowMaterializer = ActorFlowMaterializer()
implicit val ec: ExecutionContext = system.dispatcher
}
object AkkaHttpStarter extends App{
val http = new VanilaHttp with Core{
override def config: Config = ConfigFactory.load()
}
http.start()
}
trait AkkaHttp {
this: Core =>
def config: Config
def start() = {
val route: Route = {
path("dictionaries" / Segment / "suggestions"){ dictionaryId =>
get{
parameters("ngr"){ ngr =>
complete("response")
}
}
}
}
Http().bind(
interface = config.getString("frontend.interface"),
port = config.getInt("frontend.port")
).to(Sink.foreach { conn =>
conn.flow.join(route).run()
}).run()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment