http4s – streaming HTTP

The implementation of the HTTP interface in our project is based on the http4s (https://http4s.org) library. http4s is built on top of the FS2 and Cats IO and therefore we have a nice interplay with the persistence layer implemented with doobie. With http4s, it is possible to build functional server-side services using high-level DSL, as well as use it on the client-side to call HTTP APIs. We will use the client functionality to build an integration test for our API later in this chapter.

The server side is represented by HttpService[F], which is essentially just a mapping from Request to F[Response] and F is a cats IO in our case. http4s DSL helps to construct such RESTful services by using pattern-matching.

This ...

Get Learn Scala Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.