Configuring request parameters

Many applications use additional parameters along with RESTful HTTP GET requests to obtain required information. Play supports configuring these request parameters as well.

Supposing we have a request to search users by their name, we could define this as follows:

GET           /api/search/user    controllers.UserController.search(name)

Therefore, we wouldn't need to get the parameters from the request in the action. We could let Play handle acquiring the parameters from the request and passing them to the action.

What do we do when the request parameters are optional? For example, what happens if we allow a search of users by their name where lastName is optional.

We can specify Option as the type for this request parameter. Therefore, ...

Get Mastering Play Framework for 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.