Chapter 3. Routing

This chapter covers

  • Defining a route
  • Choosing the right HTTP method
  • Matching path expressions
  • Exploring advanced routes

Scalatra is often referred to as a web framework. This is fair. Scalatra ably handles requests from a web browser and responds with dynamically generated HTML. But web framework fails to tell the whole story. We prefer to call Scalatra an HTTP framework. This distinction is subtle but important.

Scalatra often serves applications unrelated to web clients. It’s used for RESTful services that may serve a mobile application or integrate internal systems. One user even uses Scalatra to provide an interface to his home heater. This is all made possible by Scalatra’s firm embrace of HTTP.

Routes are the ...

Get Scalatra in Action 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.