You are here

function services_endpoint_callback in Services 6.3

Same name and namespace in other branches
  1. 7.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
Implementation of hook_menu().

File

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

Code

function services_endpoint_callback($endpoint_name) {
  module_load_include('runtime.inc', 'services');
  $endpoint = services_endpoint_load($endpoint_name);
  $server = $endpoint->server;
  if (function_exists($server . '_server')) {

    // call the server
    if ($endpoint->debug) {
      watchdog('services', 'Calling server: %server', array(
        '%server' => $server . '_server',
      ), WATCHDOG_DEBUG);
    }
    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', '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();
}