Our Drupal site utilizes a number of menu hooks to return JSON from an API we manage in a separate Web API. We also have a number of intensive tasks that happen on each page load via the
hooks_init in several custom modules.
The issue we're facing is that the tasks in
hook_init are only required for actual pages, and should not be executed when all we want is JSON output. Is there a way to ONLY execute the
hook_menu endpoint, and no other Drupal code?
We have several pages that make 3-4 requests to Drupal JSON menu links, which means that we also run our unnecessary
hook_init tasks 3-4 times as well -- plus once for the actual page request.
There must be a way to circumvent the usual Drupal pipeline to perform these actions?
Here is an example of one of our JSON menu hooks:
// Get membership details from API, and return as JSON
$details = sendCurlResponse(/* ENDPOINT */);