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.