I just got an idea for a new application (a text snippet store, with macros, etc.), and wanted to build this around a REST API. Basically, I need to be able to do CRUD operations. (I am planning this for XP 6.9.0+, when the Node API is released, so I will not use the normal content API) So I started building a service, but I think I’ve hit a problem:
The URLs to the services are defined as */_/service/[application]/[service-name], while I would like to do have */_/service/[application]/[service-name]/[text-snippet-id] for read, update and delete operations.
Is this currently (or in the future) possible to implement in XP?
I realize I can just send the ID as params or as in the request body, but I was hoping to build a truly RESTful web service. My hope is that it could be possible to define routes in a service for everything that maps under that path.
A controller mapping is basically the same as a service, but where you can specify the URL pattern (relative to the Site). The controller can handle GET, POST, DELETE, etc, just like any other app controller.
The URL would not be based on */_service/xxx but on your site root path, and you can add a virtual path to handle the REST API. In the example below, it does not need to exist a content with path /rest/product.