I think you need an in-scope implicit FlowMaterializer (or perhaps an ActorFlowMaterializer, if you're on M3. I think that may have been resolved in M4 though)
James Sent from my iPhone > On Mar 15, 2015, at 15:17, Arthur Kushka <[email protected]> wrote: > > Hi. I was faced with a typical error with spray-json and akka-http that easy > to find in Google, but none of solutions helps me. > > Scala fail compiling in place where I parsing request body with `entity` > directive. As error say, they can`t find implicit value for unmarshaller, but > formatter and `SprayJsonSupport` are present in context (in documentation > written that that`s enough). > > Below is compiler message and my code. > Please help me with finding solution of this problem. > > [error] > /home/arhelmus/techmedia/akka-http/src/main/scala/utils/CustomDirectives.scala:31: > could not find implicit value for parameter um: > akka.http.unmarshalling.FromRequestUnmarshaller[utils.Credentials] > [error] entity(as[Credentials]).flatMap { credentials => > > > package utils > > import akka.http.marshallers.sprayjson.SprayJsonSupport > import akka.http.server.Directive1 > import models.User > import spray.json._ > > case class Credentials(login: String, password: String) > > trait Protocols extends DefaultJsonProtocol { > implicit val formatter: RootJsonFormat[Credentials] = > jsonFormat2(Credentials.apply) > } > > object CustomDirectives extends CustomDirectives > > trait CustomDirectives extends SprayJsonSupport with Protocols { > > import akka.http.server.directives.BasicDirectives._ > import akka.http.server.directives.MarshallingDirectives._ > import akka.http.server.directives.ParameterDirectives._ > > def authenticateByToken: Directive1[User] = > parameter("token").flatMap { code => > provide(User(code, "asdsada", "asdsadasd")) > } > > def authenticateByCredentials: Directive1[User] = { > entity(as[Credentials]).flatMap { credentials => > provide(User(credentials.login, credentials.login, > credentials.password)) > } > } > > } > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
