Last active
May 4, 2018 09:44
-
-
Save okapies/965bf4609adca4083ff872c094c3a270 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 $ivy.`io.skuber::skuber:2.0.5` | |
import skuber._ | |
import skuber.json.format._ | |
val nginxSelector = Map("app" -> "nginx") | |
val nginxService = Service("nginx").withSelector(nginxSelector).exposeOnNodePort(30001 -> 80) | |
import akka.actor.ActorSystem | |
import akka.stream.ActorMaterializer | |
implicit val system = ActorSystem() | |
implicit val materializer = ActorMaterializer() | |
implicit val dispatcher = system.dispatcher | |
import akka.http.scaladsl.marshalling.Marshal | |
import akka.http.scaladsl.model.RequestEntity | |
import akka.util.ByteString | |
import skuber.json.PlayJsonSupportForAkkaHttp._ | |
Marshal(nginxService) | |
.to[RequestEntity] | |
.map(_.dataBytes.runFold(ByteString.empty)(_ ++ _).map(_.utf8String)) | |
// or .map(_.toStrict(3.second).map(_.data.utf8String)) | |
.flatten | |
.foreach(println) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment