You are here

function hook_server in Services 6.3

Same name and namespace in other branches
  1. 7.3 docs/services.servers.api.php \hook_server()

Acts on requests to the server defined in hook_server_info().

This is the main entry point to your server implementation. Need to get some more description about the best way to implement servers.

3 functions implement hook_server()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

rest_server_server in servers/rest_server/rest_server.module
Starting point of the REST server.
services_edit_form_endpoint_server in plugins/export_ui/services_ctools_export_ui.class.php
xmlrpc_server_server in servers/xmlrpc_server/xmlrpc_server.module
Implementation of hook_server().

File

./services.servers.api.php, line 41
Hooks provided by Services for the definition of servers.

Code

function hook_server() {
  $endpoint_path = services_get_server_info('endpoint_path', 'services/rest');
  $canonical_path = trim(drupal_substr($_GET['q'], drupal_strlen($endpoint_path)), '/');
  $canonical_path = explode('/', $_GET['q']);
  $endpoint_path_count = count(explode('/', $endpoint_path));
  for ($x = 0; $x < $endpoint_path_count; $x++) {
    array_shift($canonical_path);
  }
  $canonical_path = implode('/', $canonical_path);
  if (empty($canonical_path)) {
    return '';
  }

  //Handle server based on $canonical_path
}