2
votes

In this link, the documentation uses instanceOf to marshal a object into JSON, as shown below:

val route = get {
  completeWith(instanceOf[Person]) { completionFunction => findPerson(completionFunction) }
}

However, when I try to use the same I get the error "unable to resolve symbol instanceOf". How can I fix this?

1
import akka.http.scaladsl.server.Directives._Stefano Bonetti
Thanks. It worked. So is instanceOf a directive? But I am not able to find instanceOf under doc.akka.io/docs/akka-http/current/scala/http/routing-dsl/…codingsplash
Not a directive, more like a helper method. See github.com/akka/akka-http/blob/master/akka-http/src/main/scala/…Stefano Bonetti
Thanks a ton! BTW, where can I read more about these helper methods? The documentation does not seem to directly talk about such helper methods.codingsplash

1 Answers

2
votes

Make sure that you always import akka.http.scaladsl.server.Directives._ or extend directives like this in your class: class MyRoutes extends Directives {. This brings into scope everything you need.

We'll work on samples to include all imports and link back to the source code so you can browse it in context in the near future.