Last active
October 29, 2015 17:33
-
-
Save longshorej/954485dc6697d8de6569 to your computer and use it in GitHub Desktop.
akka bug?
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
/* | |
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