Changeset 1498116489374d46f4e29f25eb69bff7d72ee8e1

Show
Ignore:
Timestamp:
06/29/10 16:44:13 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1277829853 +0000
git-parent:

[9d8cd3850dffe388cb5b8c8a3b937922330b067f]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1277829853 +0000
Message:

fixes #292

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_check_rest.c

    r408e1b4 r1498116  
    596596} 
    597597 
     598static int 
     599rest_show_config(noit_http_rest_closure_t *restc, 
     600                 int npats, char **pats) { 
     601  noit_http_session_ctx *ctx = restc->http_ctx; 
     602  xmlDocPtr doc = NULL; 
     603  xmlNodePtr node, root; 
     604  char xpath[1024]; 
     605 
     606  snprintf(xpath, sizeof(xpath), "/noit%s", pats ? pats[0] : ""); 
     607  node = noit_conf_get_section(NULL, xpath); 
     608 
     609  if(!node) { 
     610    noit_http_response_not_found(ctx, "text/xml"); 
     611    noit_http_response_end(ctx); 
     612  } 
     613  else { 
     614    doc = xmlNewDoc((xmlChar *)"1.0"); 
     615    root = xmlCopyNode(node, 1); 
     616    xmlDocSetRootElement(doc, root); 
     617    noit_http_response_ok(ctx, "text/xml"); 
     618    noit_http_response_xml(ctx, doc); 
     619    noit_http_response_end(ctx); 
     620  } 
     621 
     622  if(doc) xmlFreeDoc(doc); 
     623 
     624  return 0; 
     625} 
     626 
    598627void 
    599628noit_check_rest_init() { 
     629  assert(noit_http_rest_register_auth( 
     630    "GET", "/", "^config(/.*)?$", 
     631    rest_show_config, noit_http_rest_client_cert_auth 
     632  ) == 0); 
    600633  assert(noit_http_rest_register_auth( 
    601634    "GET", "/checks/", "^show(/.*)(?<=/)(" UUID_REGEX ")$",