>
> I use Either but I unmarshal all text to Left and JSON to Right
def mapPlain(entity: HttpEntity): Future[Left[String, Nothing]] = {
Unmarshal(entity).to[String].map(Left(_))
}
def mapChecking(entity: HttpEntity): Future[Right[String, AnyRef]] = {
Answer appears to be yes. Here's what my for comprehension looks like, and
the order of the DTOs in the Either doesn't matter.
val responseFuture = for {
requestEntity <- Marshal(userAttributes).to
val request = HttpRequest(method = HttpMethods.POST, uri = addUserURL,
headers =
Spoke too soon
Exception in thread "main"
akka.http.scaladsl.unmarshalling.Unmarshaller$EitherUnmarshallingException:
Failed to unmarshal Either[AddUserErrorDTO, AddUserResponseDTO] (attempted
AddUserResponseDTO first). Right failure: Object is missing required member
'id', Left failure:
Having some success with Either unmarshaller. I don't think it's
documented, but here's a test:
https://github.com/akka/akka-http/blob/master/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/UnmarshallingSpec.scala
On Tue, Aug 22, 2017 at 11:16 AM, Richard Rodseth