Chapter 5. Controllers—handling HTTP requests

 

This chapter covers

  • How to use controllers
  • Using action methods and results
  • Using routing to wire URLs to action methods
  • Composing actions with interceptors
  • Using the different scopes

In this chapter we’ll explain in detail one of the key concepts of the Play framework MVC paradigm: the controller. We’ll take a closer look at our warehouse web application and at the same time explain how interaction with a web client works in Play.

We’ll start by explaining controllers, and from there we’ll examine action methods and how we can return results to web clients. We’ll then see how to use routes to link HTTP requests to a controller’s action method. After that, we’ll look at what interceptors are and talk about what scopes are available in Play. All of these concepts are important when processing and responding to client requests.

Let’s see how we can accept and process a request from a client. First, we’ll introduce the concepts of controllers and talk some more about action methods.

5.1. Controllers and action methods

 
 
 
 

5.2. Returning results from action methods

 
 
 
 

5.3. Using routing to wire URLs to action methods

 
 

5.4. Interceptors

 
 
 

5.5. About scopes

 
 

5.6. Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage