| 141 | } |
| 142 | |
| 143 | void HttpHandler::HandleKillProcess(http::web_request &req, http::web_response &rep) { |
| 144 | int pid = 0; |
| 145 | try { |
| 146 | auto obj = nlohmann::json::parse(req.body()); |
| 147 | auto pid_str = obj["pid"].get<std::string>(); |
| 148 | pid = std::atoi(pid_str.c_str()); |
| 149 | } catch (std::exception& e) { |
| 150 | LOGE("parse json failed, body:{}", req.body()); |
| 151 | auto nr = NetResp::Make(kParamError, std::format("param error: {}", req.body()), ""); |
| 152 | rep.fill_json(nr.Dump()); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | ProcessUtil::KillProcess(pid); |
| 157 | auto nr = NetResp::Make(kNetOk, "OK", ""); |
| 158 | rep.fill_json(nr.Dump()); |
| 159 | } |
| 160 | |
| 161 | void HttpHandler::HandleResourcesFile(http::web_request &req, http::web_response &rep) { |
| 162 | std::string_view target = req.target(); |