You are here

function services_endpoint_callback in Services 7.3

Same name and namespace in other branches
  1. 6.3 services.module \services_endpoint_callback()

Menu system page callback for server endpoints.

Parameters

string $endpoint: The endpoint name.

Return value

void

1 string reference to 'services_endpoint_callback'
services_menu in ./services.module
Implements hook_menu().

File

./services.module, line 366
Provides a generic but powerful API for web services.

Code

function services_endpoint_callback($endpoint_name) {
  module_load_include('inc', 'services', 'includes/services.runtime');

  // Explicitly set the title to avoid expensive menu calls in token
  // and elsewhere.
  if (!($title = drupal_set_title())) {
    drupal_set_title('Services endpoint');
  }
  $endpoint = services_endpoint_load($endpoint_name);
  $server = $endpoint->server;
  if (function_exists($server . '_server')) {

    // call the server
    services_set_server_info_from_array(array(
      'module' => $server,
      'endpoint' => $endpoint_name,
      'endpoint_path' => $endpoint->path,
      'debug' => $endpoint->debug,
      'settings' => $endpoint->server_settings,
    ));
    if ($endpoint->debug) {
      watchdog('services', 'Calling server: %server', array(
        '%server' => $server . '_server',
      ), WATCHDOG_DEBUG);
      watchdog('services', 'Server info main object: <pre>@info</pre>', array(
        '@info' => print_r(services_server_info_object(), TRUE),
      ), WATCHDOG_DEBUG);
    }
    print call_user_func($server . '_server');

    // Do not let this output
    drupal_page_footer();
    exit;
  }

  // return 404 if the server doesn't exist
  drupal_not_found();
}