From b1887ffeaca9dc86b6d06ea1fbaab94fbc87dfac Mon Sep 17 00:00:00 2001 From: chatlanin Date: Sun, 21 Jul 2024 12:01:08 +0300 Subject: [PATCH] add rvalue to lvalue conversion --- src/trs/trs.hpp | 3 ++- tests/main.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/trs/trs.hpp b/src/trs/trs.hpp index 8a06e0b..15eddde 100644 --- a/src/trs/trs.hpp +++ b/src/trs/trs.hpp @@ -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 + auto post(std::string func_name, J&& data) { auto r = cpr::Post(cpr::Url { m_url }, cpr::Body { data.dump() }, diff --git a/tests/main.cpp b/tests/main.cpp index 8c2399c..b69ae5f 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -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");