Exemplo n.º 1
0
static int noit_httptrap_init(noit_module_t *self) {
  const char *config_val;
  httptrap_mod_config_t *conf;
  conf = noit_module_get_userdata(self);

  conf->asynch_metrics = mtev_true;
  if(mtev_hash_retr_str(conf->options,
                        "asynch_metrics", strlen("asynch_metrics"),
                        (const char **)&config_val)) {
    if(!strcasecmp(config_val, "false") || !strcasecmp(config_val, "off"))
      conf->asynch_metrics = mtev_false;
  }

  httptrap_surrogate = mtev_false;
  if(mtev_hash_retr_str(conf->options,
                        "surrogate", strlen("surrogate"),
                        (const char **)&config_val)) {
    if(!strcasecmp(config_val, "true") || !strcasecmp(config_val, "on"))
      httptrap_surrogate = mtev_true;
  }

  noit_module_set_userdata(self, conf);

  /* register rest handler */
  mtev_http_rest_register("PUT", "/module/httptrap/",
                          "^(" UUID_REGEX ")/([^/]*).*$",
                          rest_httptrap_handler);
  mtev_http_rest_register("POST", "/module/httptrap/",
                          "^(" UUID_REGEX ")/([^/]*).*$",
                          rest_httptrap_handler);
  return 0;
}
Exemplo n.º 2
0
static int
child_main() {

    /* reload our config, to make sure we have the most current */
    if(mtev_conf_load(NULL) == -1) {
        mtevL(mtev_error, "Cannot load config: '%s'\n", config_file);
        exit(2);
    }
    eventer_init();
    mtev_console_init(APPNAME);
    mtev_http_rest_init();
    mtev_capabilities_listener_init();
    mtev_events_rest_init();
    mtev_listener_init(APPNAME);
    mtev_dso_init();
    mtev_dso_post_init();

    mtev_http_rest_register("GET", "/", "^(.*)$", my_rest_handler);
    /* for 'echo-protocol' see websocket_client.js */
    mtev_http_rest_websocket_register("/", "^(.*)$", "echo-protocol", my_websocket_msg_handler);

    /* Lastly, spin up the event loop */
    eventer_loop();
    return 0;
}
Exemplo n.º 3
0
static int
check_test_init(mtev_dso_generic_t *self) {
  assert(mtev_http_rest_register(
    "POST", "/checks/", "^test(\\.xml|\\.json)?$",
    rest_test_check
  ) == 0);
  return 0;
}
void
mtev_capabilities_listener_init() {
  eventer_name_callback("capabilities_transit/1.0", mtev_capabilities_handler);
  mtev_control_dispatch_delegate(mtev_control_dispatch,
                                 MTEV_CAPABILITIES_SERVICE,
                                 mtev_capabilities_handler);
  assert(mtev_http_rest_register("GET", "/", "capa(\\.json)?",
                                 mtev_capabilities_rest) == 0);
}
Exemplo n.º 5
0
static mtev_hook_return_t late_stage_rest_register(void *cl) {
  assert(mtev_http_rest_register("GET", "/", "(.*)$", lua_web_handler) == 0);
  assert(mtev_http_rest_register("POST", "/", "(.*)$", lua_web_handler) == 0);
  return MTEV_HOOK_CONTINUE;
}