O'Reilly logo

Building Applications with Scala by Diego Pacheco

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

Creating our API with REST and JSON

Alright, now is the time to design a REST API for your Play framework application. We will create an API to export all data in the system. This API will be READ only; however, you can add write operations if you like.

Later on in this chapter, we will add some back pressure to limit the API REST rate for consumers and create a Scala client application for our REST API. So, first of all, let's get started with the Play framework (server) first.

We don't need any extra library in order to create a REST API in our Play framework application. We will just need a new controller and new routes. Additionally, we will leverage most of the code we made in the previous chapters.

RestApiContoller

Let's create a new controller ...

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