| 7 | using json = nlohmann::json; |
| 8 | |
| 9 | void Route_SendTextMsg(httplib::Server& svr) |
| 10 | { |
| 11 | svr.Post("/SendTextMsg", [](const httplib::Request& req, httplib::Response& res) |
| 12 | { |
| 13 | json reqJson; |
| 14 | json resp; |
| 15 | |
| 16 | try |
| 17 | { |
| 18 | reqJson = json::parse(req.body); |
| 19 | } |
| 20 | catch (...) |
| 21 | { |
| 22 | resp["ret"] = -1; |
| 23 | resp["msg"] = "invalid json"; |
| 24 | res.set_content(resp.dump(), "application/json"); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | std::string wxidorgid = reqJson.value("wxidorgid", ""); |
| 29 | std::string msg = reqJson.value("msg", ""); |
| 30 | |
| 31 | WeixinSend::SendText(wxidorgid, msg); |
| 32 | |
| 33 | |
| 34 | resp["ret"] = 0; |
| 35 | resp["retmsg"] = "success"; |
| 36 | |
| 37 | res.set_content(resp.dump(), "application/json"); |
| 38 | }); |
| 39 | |
| 40 | svr.Post("/Decode_Pic", [](const httplib::Request& req, httplib::Response& res) |
| 41 | { |
| 42 | json reqJson; |
| 43 | json resp; |
| 44 | |
| 45 | try |
| 46 | { |
| 47 | reqJson = json::parse(req.body); |
| 48 | } |
| 49 | catch (...) |
| 50 | { |
| 51 | resp["ret"] = -1; |
| 52 | resp["msg"] = "invalid json"; |
| 53 | res.set_content(resp.dump(), "application/json"); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | std::string src_path = reqJson.value("src_path", ""); |
| 59 | std::string dst_path = reqJson.value("dst_path", ""); |
| 60 | |
| 61 | OutputDebugStringA(("Decode_Pic src_path: " + src_path + "\n").c_str()); |
| 62 | OutputDebugStringA(("Decode_Pic dst_path: " + dst_path + "\n").c_str()); |
| 63 | |
| 64 | |
| 65 | WeixinSend::DecodePic(src_path, dst_path); |
| 66 |
no test coverage detected