It seems that it works if instead of using the default  rejection handler i 
use an explicit rejection handler as an inner directive. 

respondWithHeader(`X-Request-Id`(requestId)) {
  handleRejections(RejectionHandler.default) {
    ...


But this is rather inconvenient because some headers are set deeply nested 
within the routes. Is there an better way?



On Friday, 20 October 2017 00:15:28 UTC+2, Jelmer Kuperus wrote:
>
> In akka http I am using the respondWithHeader directive to add a 
> correlation id to the response like so
>
> final case class `X-Request-Id`(token: String) extends 
> ModeledCustomHeader[`X-Request-Id`] {
>   override def renderInRequests = true
>   override def renderInResponses = true
>   override val companion = `X-Request-Id`
>   override def value: String = token
> }
> object `X-Request-Id` extends ModeledCustomHeaderCompanion[`X-Request-Id`] 
> {
>   override val name = "X-Request-Id"
>   override def parse(value: String) = Try(new `X-Request-Id`(value))
> }
>
>
> respondWithHeader(`X-Request-Id`(requestId))
>
>
> However it seems that on rejections this header is not added to the 
> response. Is this a bug or am i missing something ?
>

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to