-1

I have an Akka HTTP server with routing defined like this:

case class FooResults(results: Seq[Tuple2[String, Tuple2[Double, Double]]])

object MainApp extends App with JsonSupport {

  ...

  lazy val routes: Route =
    pathPrefix("foo") {
      pathEnd {
        get {
          entity(as[String]) { str =>
          val results =
            (fooActor ? Foo(str)).mapTo[FooResults]
          complete(results)
      }
    }
  }
}
...

And in the class I have injected the implicit json support:

trait JsonSupport extends SprayJsonSupport {
  import DefaultJsonProtocol._
  implicit val userFormat = jsonFormat1(FooResults)
}

Somehow sbt still reports with

Type mismatch - FooResults with ToResponseMashallable

Anyone had similar problems? Thanks!

peidaqi
  • 673
  • 1
  • 7
  • 18

1 Answers1

0

I figured out myself. It was because there're two SprayJsonSupport classes in my project:

import spray.httpx.SprayJsonSupport
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport

Now obviously the latter is the correct one. Guess along the way since both Scala and Akka are evolving (fast), sometimes it becomes confusing with the namespaces and classes.

peidaqi
  • 673
  • 1
  • 7
  • 18