diff --git a/src/trs/trs.hpp b/src/trs/trs.hpp index a28298c..e6b98d5 100644 --- a/src/trs/trs.hpp +++ b/src/trs/trs.hpp @@ -78,7 +78,7 @@ namespace trs { res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Allow", "POST, HEAD, OPTIONS"); - res.set_header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Accept, Origin, Authorization, TRS-server-function, TRS-token-auth"); + res.set_header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Accept, Origin, Authorization, TRS-server-function, TRS-server-token"); res.set_header("Access-Control-Allow-Methods", "OPTIONS, HEAD, POST"); }); } @@ -120,13 +120,16 @@ namespace trs ~client() = default; public: - auto notify(std::string path, std::string key, std::string data) + auto post(std::string path, JSON&& data) { httplib::Headers headers = { - { "TRS-token-auth", m_token }, - { "TRS-server-function", "notify" } + { "TRS-server-token", m_token }, + { "TRS-server-function", "notify" }, + { "Content-Type", "application/json" }, + { "Cookie", "unione_lang=ru" } }; - return m_cli.Post(path, headers, httplib::Params{{key, data}}); + + return m_cli.Post(path.c_str(), headers, data.dump(),"application/json" ); } private: diff --git a/tests/main.cpp b/tests/main.cpp index cb2c1b3..a5a93e4 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -27,7 +27,7 @@ namespace worckspaces auto main(int argc, char* args[]) -> int { trs::client cli {"localhost:5000", "token_auth"}; - cli.notify("/","test", "test message"); + cli.post("/",trs::JSON{{ "test", "test message" }}); // trs::server srv; // srv.init("test service", "app_connection", "log_connection");