Server-side programming

For the purposes of server-side programming, we will be using libraries called HTTP4S and Circe. HTTP4S is a library with which you can bootstrap an HTTP server, accept requests, and define how to respond to them. Circe is a library with which you can convert JSON strings to domain objects.

HTTP4S leverages IO under the hood so that it can be nicely integrated into our existing database infrastructure that outputs IO, as well as so that we can be sure that our server runs asynchronously. Circe uses a technique of compile-time programming via macros (which we have already discussed briefly) to define how to convert JSON strings into Scala case classes or traits.

We are going to bootstrap our server as follows:

BlazeBuilder[IO] ...

Get Mastering Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.