How it works...
In this recipe, you learned how to use the marshaling and unmarshaling capabilities of Akka HTTP to automatically receive and send requests and responses using your code classes. To achieve this, we had SpeedMeasurementMarshallingHelper. This trait contains both a marshaler and unmarshaler for the SpeedMeasurement type.
The utf8TextSpaceMarshaller class uses the help method Marshaller.withFixedContentType to turn a SpeedMeasurement into an HttpEntity. The same way utf8TextSpaceUnmarshaller uses the help of Unmarshaller.stringUnmarshaller to read the bytes from the wire and finally turn it into a SpeedMeasurement instance.
Note that both marshaler and unmarshaler are defined as implicit. This will be required for Akka HTTP ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access