Hi Roland,

Thanks for the response.  You were correct - adding this makes the example 
work.  As you say, the error message could definitely be improved here :)

Cheers,

—James

> On Mar 11, 2015, at 4:58 PM, Roland Kuhn <[email protected]> wrote:
> 
> Hi James,
> 
> I'm on my phone right now but I think you'll need an implicit execution 
> context in scope. That error message should definitely be improved if 
> possible.
> 
> Regards,
> 
> Roland 
> 
> Sent from my iPhone
> 
> On 11 Mar 2015, at 14:24, James Mulcahy <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>> 
>> Hello,
>> 
>> I’m struggling to understand how I can complete an akka-http RequestContext 
>> asynchronously, using a future.  Synchronously completion is 
>> straightforward, e.g…...
>> 
>> val bundleRoutes = {
>>   (pathPrefix("bundles") & get) {
>>     path(Segment / "meta") {
>>       bundleId => complete {
>>         HttpResponse(entity = "Success!")
>>       }
>>     }
>>   }
>> }
>> 
>> But I can’t find what API call I need in order to return a 
>> Future[HttpResponse].  If I do the simplest change, returning a completed 
>> future inside complete()…..
>> 
>> val bundleRoutesAsync = {
>>   (pathPrefix("bundles") & get) {
>>     path(Segment / "meta") {
>>       bundleId => complete {
>>         Future.successful(HttpResponse(entity = "Success!"))
>>       }
>>     }
>>   }
>> }
>> 
>> …then the build fails with a type error (not necessarily too surprising).
>> 
>> type mismatch;
>> [error]  found   : scala.concurrent.Future[akka.http.model.HttpResponse]
>> [error]  required: akka.http.marshalling.ToResponseMarshallable
>> [error]           Future.successful(HttpResponse(entity = "Success!"))
>> 
>> I cannot see in the docs[1] what API I should use to achieve this.  Googling 
>> suggests that historically, with spray, using side-effecting calls with 
>> onComplete/onFailure was the right approach — but that doesn’t seem to be 
>> the case anymore. One thought was to return a Future[RouteResult] myself, 
>> but the RouteResult docs suggest that I shouldn’t be doing this.
>> 
>> I wonder if I’m missing an implicit marshaller that’ll handle the 
>> Future[HttpResponse] responses.
>> 
>> Could someone point me in the right direction here, please?
>> 
>> —James
>> 
>> [1] 
>> http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M4/?_ga=1.53285288.1092433602.1423525300#akka.http.server.RequestContext
>>  
>> <http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M4/?_ga=1.53285288.1092433602.1423525300#akka.http.server.RequestContext>
>> 
>> -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
>> >>>>>>>>>> Check the FAQ: 
>> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
>> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
>> >>>>>>>>>> <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] 
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected] 
>> <mailto:[email protected]>.
>> Visit this group at http://groups.google.com/group/akka-user 
>> <http://groups.google.com/group/akka-user>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <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.

Reply via email to