O'Reilly logo

Mastering Play Framework for Scala by Shiti Saxena

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Building Routes

In this chapter, we will be covering the following topics:

  • Defining the services supported by an application
  • The flow of requests received
  • Configuring routes
  • Handling assets

Introduction to Play routes

All the supported routes are specified within a single file: routes (by default). This makes it all the easier to figure out which one would be ideal.

The routes file is compiled and if any errors occur, the compilation fails.

However, the routes file is not a Scala object. So how does the compiler know what to do with the routes file? To find this out, let's perform the following steps:

  1. Let's create a project that displays a Hello, World! page. Now, define the index.scala.html home page as follows:
    <!DOCTYPE html> <html> <head> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required