void web_server::handle_post(socket_ptr socket, variant doc, const http::environment& env) { static const variant TypeVariant("type"); const std::string& type = doc[TypeVariant].as_string(); if(type == "stats") { process_stats(doc); } else if(type == "upload_table_definitions") { //TODO: add authentication to get info about the user //and make sure they have permission to update this module. const std::string& module = doc[variant("module")].as_string(); init_tables_for_module(module, doc[variant("definition")]); try { send_msg(socket, "text/json", "{ \"status\": \"ok\" }", ""); sys::write_file("stats-definitions.json", get_tables_definition().write_json()); } catch(validation_failure_exception& e) { std::map<variant,variant> msg; msg[variant("status")] = variant("error"); msg[variant("message")] = variant(e.msg); send_msg(socket, "text/json", variant(&msg).write_json(true, variant::JSON_COMPLIANT), ""); } return; } disconnect(socket); }
static void messagepoll(mycell **ref, int faction) { mps_message_t message; if (mps_message_get(&message, arena, mps_message_type_finalization())) { final_count -=1; process_mess(message, faction, (mps_addr_t*)ref); } if (mps_message_get(&message, arena, mps_message_type_gc())) { process_stats(message); } }
intptr_t process_command(connection_t *conn){ intptr_t result=OK; char *data=conn->rc->command->data; if(strcmp(data,"get")==0){ result=process_get(conn); }else if(strcmp(data,"set")==0){ result=process_set(conn); }else if(strcmp(data,"version")==0){ process_version(conn); }else if(strcmp(data,"delete")==0){ result=process_delete(conn); }else if(strcmp(data,"quit")==0){ close_connection(conn); }else if(strcmp(data,"stats")==0){ process_stats(conn); }else{ process_client_error(conn,unsupport_command); } return result; }