Creating REST resources
When creating a REST interface for your Drupal 8 site, you can use the core methods on various entities like node and create Views. You also have the option to extend the platform to create your own plugins. This allows you to get around some of the challenges presented earlier in this chapter.
Using parameters
The simplest way to get started with a new REST plugin is to use the Drupal console to create the stub of a resource that extends ResourceBase. Start by typing drupal generate:plugin:rest:resource
and then answer the prompts. We'll be recreating the functionality from the User Posts View from earlier in this chapter within the Mastering Drupal 8 module from previous chapters.

Once you've done that, you'll have a UserPostsResource.php in src/Plugin/rest/resource
of the mastering_drupal_8
module. Once you create this and rebuild the cache you'll need to enable it at Configuration
| REST
. At first, this new REST resource doesn't do very much; it just prints out ...