public function RESTServer::handle in Services 7.3
Same name and namespace in other branches
- 6.3 servers/rest_server/includes/RESTServer.inc \RESTServer::handle()
Handles the call to the REST server
File
- servers/
rest_server/ includes/ RESTServer.inc, line 35 - Class for handling REST calls.
Class
- RESTServer
- @file Class for handling REST calls.
Code
public function handle() {
$controller = $this
->getController();
$formatter = $this
->getResponseFormatter();
services_set_server_info('resource_uri_formatter', array(
&$this,
'uri_formatter',
));
// Initializing $arguments because an exception can be thrown for required
// arguments and before $arguments is initialized for the exception handler.
$arguments = array();
try {
// Parse the request data
$arguments = $this
->getControllerArguments($controller);
$result = services_controller_execute($controller, $arguments);
} catch (ServicesException $e) {
$result = $this
->handleException($e, $controller, $arguments);
$no_body = variable_get('services_no_body_responses', array(
204,
304,
));
$generate_body = variable_get('services_generate_error_body', TRUE);
if (in_array($e
->getCode(), $no_body) && !$generate_body) {
return '';
}
}
return $this
->render($formatter, $result);
}