Online
Classroom

Scala FS2 and HTTP4S

Part of our "Scala" courses

1 day

thumb image

Course Overview

A solid understanding of fs2 and http4s is essential for a more comprehensive grasp of Scala. If you are looking for an efficient and speedy polymorphic stream processing library, then FS2, or Functional Streams for Scala, is for you. It is compatible with Cats-effect typeclasses and can be used with other effect libraries. Built on FS2, HTTP4S is the ideal companion topic for this course and is the minimal Scala interface for your HTTP services.

Course Prerequisites

Students should be familiar with the Scala programming language (preferably version 3), cats and cats-effect (preferably version 3). We advice students to follow our SCALA-CATS course

Outline

fs2

  • Introduction to fs2
  • Compare fs2 to other streaming libraries
  • Defining pure streams
  • using core operations (map, flatMap, take, …)
  • Combining Streams
  • Define effectful streams
  • Understand stream compilation to F[_]
  • List key fs2 API (Stream, Pipe, Chunk, Pull, …)
  • Transforming values using pipes
  • Handling errors
  • Building Retry logic
  • Building declarative flows
  • Handling and releasing Resources
  • Introduction to Concurrency

http4s

  • Introduce https as a functional HTTP client/server
  • Introduce its Architecture
  • Understand the relevance of Kleisli, MonoidK and other typeclasses
  • Understand the role of fs2
  • Introduce Blaze

The Server and APIs/DSL

  • Configure the BlazeServer
  • Introduce the server DSL
  • Build polymorphic http4s code
  • Understand make aResponse (body, headers)
  • How to map HTTP Requests
  • Extract Path Parameters
  • Use Query Parameters
  • Introduce Entity Handing and codecs
  • Understand how EntityDecoder/EntityEncoder works
  • Using built-in codecs (strings, fs2 Stream, …)
  • Introduce/Recap Circe for Json handling
  • Integrate http4s and circe
  • Accessing the request body (for POST)
  • Adding request Validation using cats
  • Introduce and use Middleware
  • Define your own Middleware
  • Apply Middleware to your routes (logging, Authentication, CORS, etc.)
  • Testing http4s routes

The Client API/DSL

  • Set up a Blaze client
  • Introduce the client API
  • Making requests use the Client DSL
  • Handling the responses
  • Working with Headers
  • Discuss client middleware (retry, follow-redirects,.. )

Private Events

Is your team in need of a Scala FS2 and HTTP4S course?

Send us a message, and we'll get in touch, without any obligation.

languages:
enfrnl

Upcoming Public Events

Currently we have no public courses planned for Scala FS2 and HTTP4S

This Scala FS2 and HTTP4S course looks very interesting, I do however have a question