REST resource
This was a very basic example of the route and served from a PostController method. However, if you look at PostController, it has 4 more methods, and we need to serve 4 more endpoints as we discussed in Chapter 1, RESTful Web Services, Introduction and Motivation, and implemented in Chapter 3, Creating Restful Endpoints. So, we need to do the same thing in Lumen for other 4 methods. To map 4 endpoints with these 4 methods, we shouldn't need 4 more routes. We can simply add a resource-based route which will map REST based URL patterns to all methods in PostController.
As we created PostController through the command line, it created a Resource Controller which means it has the necessary methods to serve RESTful endpoints. So ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access