Created
June 16, 2016 23:01
-
-
Save searler/db90de8fbcc0890c584a79ecf775c976 to your computer and use it in GitHub Desktop.
Marshalling a simple case class to/from string representation for Akka HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class A(code:Int) | |
import akka.http.scaladsl.marshalling.PredefinedToEntityMarshallers._ | |
import akka.http.scaladsl.unmarshalling.PredefinedFromEntityUnmarshallers._ | |
implicit val aResponseUnmarshaller = stringUnmarshaller.map {s:String => A(s.toInt) } | |
implicit val aResponseMarshaller = StringMarshaller.compose{p:A => p.code.toString} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment