add rvalue to lvalue conversion

This commit is contained in:
chatlanin 2024-07-21 12:01:08 +03:00
parent af5fffc9d0
commit b1887ffeac
2 changed files with 6 additions and 3 deletions

View File

@ -148,7 +148,8 @@ namespace trs
// return m_cli.Post("/", headers, data.dump(), var::HEADER_FLAG_JSON );
// }
auto post(std::string func_name, JSON&& data)
template<typename J>
auto post(std::string func_name, J&& data)
{
auto r = cpr::Post(cpr::Url { m_url },
cpr::Body { data.dump() },

View File

@ -45,8 +45,10 @@ auto main(int argc, char* args[]) -> int
trs::client cli {"localhost:5000"};
cli.set_token("token");
trs::client cli_2 { std::move(cli) };
auto r = cli_2.post("func_name", trs::JSON{{ "key", "test message" }});
hack::log()(r.text, r.status_code);
auto r1 = cli_2.post("func_name", trs::JSON{{ "key", "test message" }});
auto j = trs::JSON{{ "key", "test message" }};
auto r2 = cli_2.post("func_name", j);
hack::log()(r1.text, r2.status_code);
trs::server srv;
srv.init("test service");