Re: [akka-user] Behavior of akka 2.4.3 with modeled custom headers

2016-04-06 Thread Akka Team
Hi Chris,

This seems like a regression bug, please file a ticket thanks!

On Tue, Apr 5, 2016 at 7:46 PM, Chris Baxter  wrote:

> So I have some custom modeled headers, with one of them being defined like
> so:
>
> object `X-Access-Token` extends
> ModeledCustomHeaderCompanion[`X-Access-Token`]{
>
>   override val name = "X-Access-Token"
>
>   override def parse(value:String) = util.Try(`X-Access-Token`(value))
>
> }
>
> case class `X-Access-Token`(token:String) extends
> ModeledCustomHeader[`X-Access-Token`] with DefaultHeaderRendering{
>
>   override val companion = `X-Access-Token`
>
>   val value = token
>
> }
>
>
> Using akka 2.4.3, if I pass it in on a request as:
>
>
> X-Access-Token: abc123
>
>
> and then in a route extract it via headerValueByType[`X-Access-Token`] the
> value of the token on the case class produced is "X-Access-Token: abc123"
> (included the header name) instead of the expected "abc123".  I tracked
> this down to the HeaderMagnet used for modeled headers:
>
>
> implicit def fromUnitForModeledCustomHeader[T <: ModeledCustomHeader[T],
> H <: ModeledCustomHeaderCompanion[T]]
>
> (u: Unit)(implicit tag: ClassTag[T], companion:
> ModeledCustomHeaderCompanion[T]): HeaderMagnet[T] =
>
> new HeaderMagnet[T] {
>
>   override def runtimeClass = tag.runtimeClass.asInstanceOf[Class[T]]
>
>   override def classTag = tag
>
>   override def extractPF = {
>
> case h if h.is(companion.lowercaseName) => companion.apply(h
> .toString)
>
>   }
>
> }
>
>
> In extractPF, it's using the companion.apply with h.toString instead of
> just the .value of the header.  Am I supposed to be parsing out the value
> from that string in .parse on my companion because if that's the case it's
> not clear from the docs.  This all worked correctly in 2.4.2.
>
> --
> >> 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.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>  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.


[akka-user] Behavior of akka 2.4.3 with modeled custom headers

2016-04-05 Thread Chris Baxter
So I have some custom modeled headers, with one of them being defined like 
so:

object `X-Access-Token` extends 
ModeledCustomHeaderCompanion[`X-Access-Token`]{

  override val name = "X-Access-Token"

  override def parse(value:String) = util.Try(`X-Access-Token`(value))

}

case class `X-Access-Token`(token:String) extends 
ModeledCustomHeader[`X-Access-Token`] with DefaultHeaderRendering{

  override val companion = `X-Access-Token`

  val value = token

}


Using akka 2.4.3, if I pass it in on a request as:


X-Access-Token: abc123


and then in a route extract it via headerValueByType[`X-Access-Token`] the 
value of the token on the case class produced is "X-Access-Token: abc123" 
(included the header name) instead of the expected "abc123".  I tracked 
this down to the HeaderMagnet used for modeled headers:


implicit def fromUnitForModeledCustomHeader[T <: ModeledCustomHeader[T], H 
<: ModeledCustomHeaderCompanion[T]]

(u: Unit)(implicit tag: ClassTag[T], companion: 
ModeledCustomHeaderCompanion[T]): HeaderMagnet[T] =

new HeaderMagnet[T] {

  override def runtimeClass = tag.runtimeClass.asInstanceOf[Class[T]]

  override def classTag = tag

  override def extractPF = {

case h if h.is(companion.lowercaseName) => companion.apply(h
.toString)

  }

}


In extractPF, it's using the companion.apply with h.toString instead of 
just the .value of the header.  Am I supposed to be parsing out the value 
from that string in .parse on my companion because if that's the case it's 
not clear from the docs.  This all worked correctly in 2.4.2.

-- 
>>  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.