Created
October 6, 2015 22:40
-
-
Save tloudon/57365bf58c4eefdc3741 to your computer and use it in GitHub Desktop.
example api check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$api_check = FALSE; | |
$headers = getallheaders(); | |
foreach($headers as $key => $value) { | |
if (stripos($key, 'X-API') !== FALSE) { | |
$api_check = TRUE; | |
} | |
} | |
// you get the idea ^ | |
// so contrib modules can get patches to opt-out of expensive hook_init/hook_boot or whatever rendering | |
// needs that may be horribly expensive and unnecessary for an API call | |
// eg | |
// some_awesome_module_init() { | |
// if (i_can_has_api()) { | |
// return; | |
// } | |
// // beautiful, world-changing code that sadly does not help w/ teh JSONs... | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hook_page_build/hook_page_alter is where a lot of hook_init code should go. I use this inside the advagg font module http://cgit.drupalcode.org/advagg/tree/advagg_font/advagg_font.module#n23