Skip to content

Instantly share code, notes, and snippets.

@longshorej
Last active October 29, 2015 17:33
Show Gist options
  • Save longshorej/954485dc6697d8de6569 to your computer and use it in GitHub Desktop.
Save longshorej/954485dc6697d8de6569 to your computer and use it in GitHub Desktop.
akka bug?
/*
name := "bug"
version := "1.0"
organization := "com.github.longshorej"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http-experimental" % "1.0"
)
scalaVersion := "2.11.7"
*/
package com.github.longshorej
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server._
import akka.stream.ActorMaterializer
import akka.http.scaladsl.marshalling.PredefinedToEntityMarshallers
import akka.http.scaladsl.model.MediaTypes
object Main extends App {
implicit val as = ActorSystem()
implicit val mat = ActorMaterializer()
implicit val sm = PredefinedToEntityMarshallers.stringMarshaller(MediaTypes.`text/html`)
val route =
path("test") {
get {
complete("<form method='post' action='/test'><input type='text' name='test' /><input type='text' name='test2' /><input type='submit' />")
} ~ post {
formFields("test", "test2") { case (test, test2) => complete(s"got $test $test2") }
}
}
val serverBinding = Http().bindAndHandle(route, "0.0.0.0", 8081)
println("server listening on port 8081")
println("press return to stop")
Console.readLine()
import as.dispatcher
serverBinding
.flatMap(_.unbind())
.onComplete(_ => as.shutdown())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment