oh! That was it! thanks ;)
I'll remember to check if they add it to the documentation once it's
released.
Cheers
G
On Thursday, 12 March 2015 10:00:46 UTC, Mark Hatton wrote:
>
> Completing a route with a Tuple3[StatusCode, Seq[HttpHeader], T] doesn't
>> seem to work for me.
>
>
> Ensure your headers collection is an instance of immutable.Seq. E.g.:
>
> import collection.immutable._
>
> complete( (OK, Seq(`Cache-Control`(`no-cache`)), responseEntity) )
>
>
> Works for me.
>
> Mark
>
>
> On Thursday, March 12, 2015 at 12:18:28 AM UTC, Giovanni Alberto
> Caporaletti wrote:
>>
>> This is what I came up with (I have another question below):
>>
>> def onSuccessHead(magnet: OnStreamSuccessHeadMagnet): Directive[magnet.Out]
>> = {
>> magnet.directive
>> }
>>
>> trait OnStreamSuccessHeadMagnet {
>> type Out
>> def directive: Directive[Out]
>> }
>>
>> object OnStreamSuccessHeadMagnet {
>> import akka.http.server.directives.FutureDirectives._
>>
>> implicit def apply[T](s: Source[T, _])(implicit mat:
>> ActorFlowMaterializer, tupler: Tupler[T]) = {
>> new OnStreamSuccessHeadMagnet {
>> type Out = tupler.Out
>> val directive =
>> onSuccess(s.runWith(Sink.head("SourceMarshallerHeadSink")): Future[T])
>> }
>> }
>>
>> }
>>
>>
>> and the route:
>>
>> onSuccessHead(userService.createUser(req)) { newUser =>
>> respondWithHeader(Location(s"/$v1/$user/${newUser.id}")) {
>> complete(Created -> newUser)
>> }
>> }
>>
>>
>>
>> By the way, is there a way of extracting "constant" paths? e.g. my path
>> is path("v1" / "user") but I don't want to have separate constants for v1
>> and user and something like path("some" / "path") { (some, path) => ...}
>> doesn't work. In other words, how do you do reverse routing in spray/akka
>> http?
>>
>> Thanks
>> G
>>
>>
>> On Thursday, 12 March 2015 00:10:24 UTC, Giovanni Alberto Caporaletti
>> wrote:
>>>
>>> Hi,
>>> Completing a route with a Tuple3[StatusCode, Seq[HttpHeader], T]
>>> doesn't seem to work for me. My json4s marshaller serializes the whole
>>> tuple as an object. Tuple2[StatusCode, T] works instead.
>>> Are there any plans to implement it?
>>>
>>> What's the best way to add headers to a response anyway? In my case the
>>> header depends on a future (or, well, on a materialization of a stream).
>>>
>>>
>>> Thank you
>>>
>>> Cheers
>>> G
>>>
>>
--
>>>>>>>>>> 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.