How it works...
In this recipe, you learned how to use encoding and decoding with both server and client APIs from Akka HTTP. On the server side, we used the directives decodeRequestWith and encodeRequest. decodeRequestWith tries to decode the HTTP entity of the request based on the HTTP header Content-Encoding with the provided decoders, in our case, Gzip or NoCoding. encodeRequest tries to encode the HTTP entity of the response based on the HTTP header Accept-Encoding. If this header is not provided, Akka HTTP won't encode your response.
On the client side, we prepared two requests: one with no coding and one compressed with gzip. For the one with the gzip content, we had to provide the Content-Encoding header to inform the server that ...
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