void FoldersService::render_DELETE(const http_request& req, http_response** res) { if (req.get_user()=="a" && req.get_pass()=="a") { string strid = req.get_arg("id"); CUUID id = CUUID::Parse(strid); HisDevFolder* folder = dynamic_cast<HisDevFolder*>(root->GetFolder()->Find(id)); if (folder!=NULL) { HisDevFolder* parentfolder = dynamic_cast<HisDevFolder*>(folder->GetParent()); parentfolder->Remove(id); delete(folder); root->Save(); *res = new http_string_response("", 200, "application/json"); return; } } else { string message = "Autentication error"; *res = new http_string_response(message.c_str(), 401, "application/json"); return; } *res = new http_string_response("", 403, "application/json"); }
void FoldersService::render_PUT(const http_request& req, http_response** res) { if (req.get_user()=="a" && req.get_pass()=="a") { string strid = req.get_arg("id"); string content = req.get_content(); if (UpdateFolder(strid,content)) { *res = new http_string_response("", 200, "application/json"); return; } } else { string message = "Autentication error"; *res = new http_string_response(message.c_str(), 401, "application/json"); return; } *res = new http_string_response("", 403, "application/json"); }