Commit 7ca93c0a authored by Jonathan Hunt's avatar Jonathan Hunt

#53 Enable content negotiation on place and route paths.

parent 8dbfed00
......@@ -343,16 +343,18 @@ function climbnz_api_services_resources() {
* Implements hook_node_view().
*/
function climbnz_api_node_view($node, $view_mode, $langcode) {
if (substr($_SERVER['HTTP_ACCEPT'], 0, 12) == 'application/') {
if (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== FALSE) {
if ($node->type == 'place' && $view_mode == 'full') {
// Return via services, force path to be Place node.
drupal_add_http_header('Vary', 'Accept', TRUE);
$_GET['q'] = 'api/place/' . $node->nid;
$endpoint_name = 'climbnz_api1';
return services_endpoint_callback($endpoint_name);
}
if ($node->type == 'route' && $view_mode == 'full') {
// Return via services, force path to be Place node.
// Return via services, force path to be Route node.
drupal_add_http_header('Vary', 'Accept', TRUE);
$_GET['q'] = 'api/route/' . $node->nid;
$endpoint_name = 'climbnz_api1';
return services_endpoint_callback($endpoint_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment