You are here

function little_helpers_deliver_json in Little helpers 7.2

Same name and namespace in other branches
  1. 7 little_helpers.module \little_helpers_deliver_json()

Delivery callback: JSON response.

File

./little_helpers.module, line 92
Hook implementations and supplementary functions availably in any request.

Code

function little_helpers_deliver_json($result) {
  switch ($result) {
    case MENU_NOT_FOUND:
      drupal_add_http_header('Status', '404 Not found');
      return;
    case MENU_ACCESS_DENIED:
      drupal_add_http_header('Status', '403 Forbidden');
      return;
    case 405:
      drupal_add_http_header('Status', '405 Method Not Allowed');
      return;
    case 502:
      drupal_add_http_header('Status', '502 Bad Gateway');
      return;
    case MENU_SITE_OFFLINE:
      drupal_add_http_header('Status', '503 Service unavailable');
      return;
  }
  echo drupal_json_output($result);
  drupal_page_footer();
}