tripal_ws.module 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Implements hook_init()
  4. */
  5. function tripal_ws_init() {
  6. global $base_url;
  7. $version = 'v0.1';
  8. $api_url = $base_url . '/ws/' . $version;
  9. // Following the WC3 Hydra documentation, we want to add LINK to the header
  10. // of the site that indicates where the API documentation can be found.
  11. // This allows a hydra-enabled client to discover the API and use it.
  12. $attributes = array(
  13. 'rel' => 'http://www.w3.org/ns/hydra/core#apiDocumentation',
  14. 'href' => $api_url . '/ws-doc/',
  15. );
  16. drupal_add_html_head_link($attributes, $header = FALSE);
  17. }
  18. /**
  19. * Implements hook_menu().
  20. * Defines all menu items needed by Tripal Core
  21. *
  22. * @ingroup tripal_ws
  23. */
  24. function tripal_ws_menu() {
  25. // Web Services API callbacks.
  26. $items['ws/v0.1'] = array(
  27. 'title' => 'Tripal Entities Web Services API v0.1',
  28. 'page callback' => 'tripal_ws_rest',
  29. 'access arguments' => array('access content'),
  30. 'file' => '/includes/tripal_ws.rest.inc',
  31. 'type' => MENU_CALLBACK,
  32. );
  33. return $items;
  34. }