Skip to content

Instantly share code, notes, and snippets.

@susliko
Created June 7, 2019 13:38
Show Gist options
  • Select an option

  • Save susliko/9a0d90f3de76626ef7e56e60c5e07c04 to your computer and use it in GitHub Desktop.

Select an option

Save susliko/9a0d90f3de76626ef7e56e60c5e07c04 to your computer and use it in GitHub Desktop.
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.stream.{ActorMaterializer, Materializer}
import korolev._
import korolev.akkahttp._
import korolev.execution._
import korolev.server._
import korolev.state.javaSerialization._
import scala.concurrent.Future
object AkkaHttpExample extends App {
private implicit val actorSystem: ActorSystem = ActorSystem()
private implicit val materializer: Materializer = ActorMaterializer()
val applicationContext = Context[Future, Boolean, Any]
import applicationContext._
import symbolDsl._
private val config = KorolevServiceConfig[Future, Boolean, Any](
stateStorage = StateStorage.forDeviceId(deviceId =>
Future{
println("here")
false
}
),
router = emptyRouter,
render = { case s =>
'body(
s"Hello akka-http: $s",
'button("Click me!",
event('click)(_.transition(!_))
)
)
}
)
private val route = akkaHttpService(config).apply(AkkaHttpServerConfig())
Http().bindAndHandle(route, "0.0.0.0", 8080)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment