public function testUrlPrefix()
 {
     $config = new ResourceConfiguration('path/to/resource', 'my_module', $this->class, $this->auth, 'myprefix');
     $this->assertEquals('myprefix/path/to/resource', $config->getPath());
     $config = new ResourceConfiguration('/path/to/resource', 'my_module', $this->class, $this->auth, '/myprefix/');
     $this->assertEquals('myprefix/path/to/resource', $config->getPath());
 }
예제 #2
0
/**
 * Allows modification of the request before the resource responds to it. An
 * exception may be thrown in this hook to stop further processing of the
 * request.
 *
 * In order to affect a change to the request object, it must be returned from
 * this function.
 *
 * @param string $path
 *   The path of the resource being accessed.
 * @param ResourceConfiguration $resource
 *   A ResourceConfiguration object.
 * @param JsonRequest $request
 *   The request object.
 *
 * @return mixed
 *   If changes to the request need to be propagated, a modified request must be
 *   returned. If nothing is returned, changes to the request will not available
 *   downstream.
 *
 */
function hook_restapi_request($path, ResourceConfiguration $resource, JsonRequest $request)
{
    // Logs statsd data on our endpoints. Note that the $path represents the
    // actual path being called, while the ResourceConfiguration::getPath() is the
    // configured path (which may contain wildcards). The latter may also differ
    // from the former in cases where internal calls are made.
    if (module_exists('statsd')) {
        statsd_call('restapi.' . $resource->getPath());
    }
}