resource
keyword. As shown in the example below, we are declaring the /messages
path as a resource path. As part of the declaration, we specify what controller the resource path should use to create its complete routes.create
/
/messages
getAll
/
/messages
getOne
/:rcId
/messages/:messageId
update
/:rcId
/messages/:messageId
delete
/:rcId
/messages/:messageId
count
/count
/messages/count
allow
or deny
keyword to permit or prohibit actions on the resource, respectively. If you use the allow
keyword, then all resource actions are prohibited except the ones listed. Likewise, if you use the deny
keyword, then all resource actions are permitted except for the ones listed.Controller
class, you extend the ResourceController
class. The ResourceController
class has a methods that correspond to each action listed in the table above. You just have to provide the corresponding implementation for each supported action.ResourceController
class has empty methods for each action by design. This is because the implementation of a resource controller depends heavily on where the data is persisted. For example, a in-memory resource controller will store its resources in memory. Whereas, a MongoDB resource controller will persists is resources to a MongoDB database. We therefore recommend that you leverage a domain-specific resource controller since it will provide a default implementation for each action while giving you the ability to customize it accordingly.