Hi Rafal,
thank you very much!
I remember having encountered a similar problem using Spray which i solved
by using a respondWithStatus directive. Now, both cases make perfect sense
:>
Best,
Constantin
On Sunday, March 6, 2016 at 1:18:02 AM UTC+1, Rafał Krzewski wrote:
>
> Hi Constantin,
>
> you got it _almost_ right! Just change the type of implicit from
> ToReponseMarshaller to ToEntityMarshaller and you are good to go.
>
> RouteDirectives.complete expects a (m: ⇒ ToResponseMarshallable) but you
> are providing a (StatusCode, A) pair.
> PredefinedToResponseMarshallers.fromStatusCodeAndValue can fix that, but
> it needs a ToEntityMarshaller[A] to fill the gap.
>
> cheers,
> Rafał
>
> W dniu piątek, 4 marca 2016 14:01:50 UTC+1 użytkownik Constantin
> Gerstberger napisał:
>>
>> Hi,
>>
>> i' trying to build a custom directive which completes a *Future *of
>> *Either*. However, the following only works if i omit the status code
>> when completing the *Right* case (i.e. *complete(result)* ).
>>
>> def completeEither[A](successStatusCode: StatusCodes.Success, future: =>
>> Future[Either[RequestError, A]])(implicit m: ToResponseMarshaller[A]) =
>> onSuccess(future) {
>> case Right(result) =>
>> complete(successStatusCode -> result)
>> case Left(BadRequest(message)) =>
>> complete(StatusCodes.BadRequest -> message)
>> case Left(_) =>
>> complete(StatusCodes.InternalServerError)
>> }
>>
>>
>> The compile error i get is: *Type mismatch, expected:
>> ToResponseMarshallable, actual: (StatusCodes.Success, A)*
>> I understand what the error message means but not where it comes from.
>> Based on this post
>> <https://groups.google.com/forum/#!topic/akka-user/jUEJm6UVItk> and due
>> to the implicit parameter, i'd assume that it should work.
>>
>> Could anyone explain what i'm doing wrong?
>>
>> Thanks & regards
>> Constantin
>>
>>
>>
>>
>>
>>
>>
--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.