Problem
Modules can set or alter a resource's endpoint through hook_restws_resource_info[_alter]()
via the menu_path
item. One of the examples given in restws.api.php
is setting the menu path for 'Book' to 'api/mybook'. We are trying to use the menu_path
property to change the resource endpoints on drupal.org (exposing for example the node resource under /api-d7/node/12345.json instead of /node/12345.json), see #1710850: Deploy RestWS for D7 project issue JSON.
However, restws_page_callback
is hardcoded to always use the first element as resource, the second element as resource id. Hence, any menu_path
containing more than one part will result in a 404.
/**
* Menu page callback.
*/
function restws_page_callback($resource, $page_callback = NULL) {
$id_arg = arg(1);
$resource_arg = arg(0);
$format = FALSE;
$id = NULL;
Proposed solution
If set, take the menu_path
property of a resource into account when determining the position of resource and resource ID in the path.
Comment | File | Size | Author |
---|---|---|---|
restws_multipart.patch | 752 bytes | mr.baileys |
Comments
Comment #1
klausiYep, the menu path option is a bit broken right now since #1697558: Properly document and implement "menu_path" was never finished.
Patch looks good, but tests are missing. Please continue in the other issue.