18 The time HTTP server

In this capstone, you will

  • Define partial functions and pattern matching constructs
  • Handle exceptions using a try-catch expression
  • Implement an HTTP server using http4s

In this lesson, you’ll adapt the code you wrote in the previous capstone to implement an HTTP server to provide the current date and time for a given country (e.g., “Italy” or “Japan”). In particular, you’ll expose and an HTTP API to return a representation of the current date and time, or a human-readable error message.

18.1 What time is it?

Let’s define an API that reflects the business requirements. Your server should be able to handle GET requests ...

Get Get Programming with Scala 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.