Menu
  • HOME
  • TAGS

How to unmarshall akka http request entity as string?

json,scala,akka-http

Your code should be okay provided you have the right implicits in scope. If you have an implicit FlowMaterializer in scope then things should work as expected as this code that compiles shows: import akka.http.scaladsl.server.Route import akka.actor.ActorSystem import akka.stream.ActorFlowMaterializer import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.server.Directives._ import akka.stream.FlowMaterializer implicit val system = ActorSystem("test")...

could not find implicit …: akka.http.server.RoutingSetup

scala,akka,akka-http

With research I was able to understand the issue to be lack of Execution Context. To solve both the issue I needed to include this: implicit val executionContext = system.dispatcher Looking into akka/http/marshalling/ToResponseMarshallable.scala I see ToResponseMarshallable.apply requires it which returns a Future[HttpResponse]. Also, in akka/http/server/RoutingSetup.scala, RoutingSetup.apply needs it. May be...

How to make HTTPS (not HTTP) request use akka-http?

akka,akka-http

If you take a look on the official documentation (http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC4/scala/http/client-side/https-support.html), you can see that you have to configure the HTTPS context. Then it should work.

What to import for this code to work (and in general)?

scala,intellij-idea,import,akka,akka-http

I think the following code should show the structure you need (requiring an implicit ExecutionContext) as well as the import to give you the routing DSL: import akka.http.server._ import scala.concurrent.ExecutionContext class MyDataService(implicit ec:ExecutionContext) { import Directives._ val route: Route = path("data" / IntNumber) { id => get { complete {...