Hi Martynas,

thanks!! It's working:
https://github.com/sphereio/cloudqueues-simulator/commit/ac78061ce85746ced11e7c85891205d9b1f8ded3


Le jeu. 16 avr. 2015 à 14:45, Martynas Mickevičius <
[email protected]> a écrit :

> Hi Yann,
>
> you need to have an implicit unmarshaller from string to your value class
> in scope. One like this should be sufficient:
>
> implicit val claimUnmarshaller =
> akka.http.unmarshalling.Unmarshaller.strict[String, ClaimId](ClaimId)
>
> On Wed, Apr 15, 2015 at 11:44 AM, Yann Simon <[email protected]>
> wrote:
>
>> For type safety, I use a value class for IDs, like:
>> case class ClaimId(id: String) extends AnyVal {
>>   override def toString: String = id
>> }
>>
>> I'd like to read this id from a query parameter.
>> For the moment, I use this:
>> parameter('claim_id.as[String] ?) { claimId ⇒
>>   ... claimId.map(ClaimId.apply) ...
>> }
>> (see the code here:
>> https://github.com/sphereio/cloudqueues-simulator/blob/master/src/main/scala/io/sphere/cloudqueues/Routes.scala#L123
>> )
>>
>> I'd prefer to read directly into a ClaimId, like that:
>> parameter('claim_id.as[ClaimId] ?) { claimId ⇒ ... }
>>
>> Can somebody show me how to do that?
>>
>> All ParamMagnet, ParamDef are sealed traits that I cannot use.
>> I checked the existing tests (
>> https://github.com/akka/akka/blob/releasing-akka-stream-and-http-experimental-1.0-M5/akka-http-tests%2Fsrc%2Ftest%2Fscala%2Fakka%2Fhttp%2Fserver%2Fdirectives%2FParameterDirectivesSpec.scala)
>> but have not found something similar.
>>
>> Thanks,
>> Yann
>>
>  --
>> >>>>>>>>>> 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.
>>
>
>
>
> --
> Martynas Mickevičius
> Typesafe <http://typesafe.com/> – Reactive
> <http://www.reactivemanifesto.org/> Apps on the JVM
>
> --
> >>>>>>>>>> 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.
>

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