Changeset 1498116489374d46f4e29f25eb69bff7d72ee8e1
- Timestamp:
- 06/29/10 16:44:13
(8 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
r408e1b4 |
r1498116 |
|
596 | 596 | } |
---|
597 | 597 | |
---|
| 598 | static int |
---|
| 599 | rest_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 | |
---|
598 | 627 | void |
---|
599 | 628 | noit_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); |
---|
600 | 633 | assert(noit_http_rest_register_auth( |
---|
601 | 634 | "GET", "/checks/", "^show(/.*)(?<=/)(" UUID_REGEX ")$", |
---|