Desktop version

Home arrow Computer Science arrow Building Applications with Scala

Source

Configuring new routes

We need to add the following three new routes for our REST API, which is located at

ReactiveWebStore/conf/routes:

#

# REST API

#

GET /REST/api/product/all

controllers.RestAPIController.listAllProducts GET /REST/api/review/all

controllers.RestAPIController.listAllReviews

GET /REST/api/image/all controllers.RestAPIController.listAllImages

As you can see, we mapped all the list operations we just created.

Testing the API using the browser

Now we can run $ activator run and test our new REST API using our web browser. Go to http://localhost:9000/REST/api/product/all; you should see something similar to the following screenshot:

Let's look at the review API.

Go to http://localhost:9000/REST/api/review/all; you should see results similar to the following screenshot:

Finally, let's check out the image of REST API.

Go to http://localhost:9000/REST/api/image/all; you should see results similar to the following screenshot:

OK. Now we will continue to work with REST. We just finished the server; however, it is important to create a REST client to consume these REST APIs.

 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >

Related topics