Created
June 7, 2019 13:38
-
-
Save susliko/9a0d90f3de76626ef7e56e60c5e07c04 to your computer and use it in GitHub Desktop.
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
| 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