Day 3 -

Aug 20th

Stage 1

16:10 - 16:50

Routing Http Requests with Scala 3

Request routing is the problem of choosing a function to invoke based on a HTTP request. All but the simplest web frameworks include routing, but that doesn’t mean that routing isn’t an interesting problem. I set out to design a request routing library that was all of:

  • compositional;
  • type safe;
  • reversible, meaning clients can be constructed from a route; and
  • a delight to use, with great error messages.

Doing requires some interesting design decisions. We’ll discuss FP versus OO representations, finite state machine builders (which are a lot simpler than this name implies!), using Scala 3’s tuple types for greater type safety and convenience, and designing for dot-driven development. Along the way I’ll discuss other routing libraries that made different decisions, to help illustrate the design space and the tradeoffs that can be made.

Did I succeed? Well, you can decide. Either way, I think the journey is interesting and you should learn something you can apply to your own coding.

Noel Welsh

Inner Product

Noel is a developer, teacher, and author. He’s worked with companies big and small across Europe, the USA, and even once in Africa. He’s the organizer of ScalaBridge London, a diversity focused group helping people get better at Scala. When he’s not programming Scala he is probably writing about it. His next book, Functional Programming Strategies, is out soon!

Subscribe

Join our conference

Subscribe and follow @ScalaDays on BlueSky for the latest conference updates.