Marshalling & Unmarshalling
"Marshalling" is the process of converting a higher-level (object) structure into some kind of lower-level representation (and vice versa), often a binary wire format. Other popular names for it are "Serialization" or "Pickling".
In akka-http "Marshalling" means the conversion of an object of type T into an HttpEntity, which forms the entity body of an HTTP request or response (depending on whether used on the client or server side).
On the server-side marshalling is used to convert a application-domain object to a response (entity). Requests can
Accept header that lists acceptable content types for the client. A marshaller contains the logic to
negotiate the result content types based on the
Accept and the
Marshallers can be specified when completing a request with
RequestContext.completeAs or by using the
These marshallers are provided by akka-http:
On the server-side unmarshalling is used to convert a request (entity) to a application-domain object. This means
unmarshalling to a certain type is represented by a
RequestVal. Currently, several options are provided to create
- Use Json Support via Jackson to create an unmarshaller that can convert an
application/jsonrequest to a POJO using jackson.
- Use the predefined
Unmarshallers.CharArrayto convert to those basic types.
Unmarshaller.fromEntityto create a custom unmarshaller.