Unit 3. HTTP server

 

In unit 2, you mastered the fundamentals of object-oriented programming in Scala and built an executable sbt application to print the current date and time in the given timezone. In this unit, you’ll adapt the code you wrote for the previous capstone to transform your application into an HTTP server. You’ll define an HTTP API to return the current date and time for a given country rather than a given time zone using http4s, a popular library to manage HTTP requests and responses. In particular, you’ll learn about the following subjects:

  • Lesson 14 teaches you about pattern matching, a powerful and useful tool to combine your program’s different execution flows based on some predefined condition.
  • Lesson 15 shows you what anonymous functions are and how to define them more quickly and concisely.
  • Lesson 16 introduces partial functions as a type of anonymous function defined only for some input values. You’ll use partial functions when implementing the routing of your HTTP server.
  • Lesson 17 illustrates how to use the library http4s to handle GET HTTP requests and responses.
  • Finally, you will apply these concepts and implement an HTTP server to return the current date and time of a given country in lesson 18.

Once you have learned how to implement and run an HTTP server, you’ll continue your journey with unit 4, where you’ll see how to represent your data using immutable structures.