fix function name
This commit is contained in:
parent
4b534505c2
commit
1b963a7486
@ -10,7 +10,7 @@ namespace trs
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fm.valid(tr.m_passport.m_func_name);
|
fm.valid(tr.m_passport.m_function_name);
|
||||||
}
|
}
|
||||||
catch (hack::exception& ex)
|
catch (hack::exception& ex)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace trs
|
|||||||
|
|
||||||
void execute(Transaction& tr)
|
void execute(Transaction& tr)
|
||||||
{
|
{
|
||||||
m_functions[tr.m_passport.m_func_name](tr);
|
m_functions[tr.m_passport.m_function_name](tr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ namespace trs
|
|||||||
|
|
||||||
void valid(Transaction& tr)
|
void valid(Transaction& tr)
|
||||||
{
|
{
|
||||||
if (!valid(tr.m_passport.m_func_name))
|
if (!valid(tr.m_passport.m_function_name))
|
||||||
{
|
{
|
||||||
hack::exception ex;
|
hack::exception ex;
|
||||||
ex.description("Function is not register in inspector. Please do it");
|
ex.description("Function is not register in inspector. Please do it");
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_functions[tr.m_passport.m_func_name](tr);
|
m_functions[tr.m_passport.m_function_name](tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -21,7 +21,7 @@ namespace trs
|
|||||||
struct passport
|
struct passport
|
||||||
{
|
{
|
||||||
int m_id = -1000; // Эта сущность, которая зашифрована в токене. Например id организации
|
int m_id = -1000; // Эта сущность, которая зашифрована в токене. Например id организации
|
||||||
std::string m_func_name;
|
std::string m_function_name;
|
||||||
std::string m_token = "no token";
|
std::string m_token = "no token";
|
||||||
} m_passport;
|
} m_passport;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace trs
|
|||||||
{
|
{
|
||||||
JSON j;
|
JSON j;
|
||||||
j["transaction_id"] = m_transaction_id;
|
j["transaction_id"] = m_transaction_id;
|
||||||
j["func_name"] = m_passport.m_func_name;
|
j["function_name"] = m_passport.m_function_name;
|
||||||
j["token"] = m_passport.m_token;
|
j["token"] = m_passport.m_token;
|
||||||
j["payload"] = m_data.m_payload;
|
j["payload"] = m_data.m_payload;
|
||||||
j["result"] = m_data.m_result;
|
j["result"] = m_data.m_result;
|
||||||
@ -59,8 +59,8 @@ namespace trs
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_passport.m_func_name = req.get_header_value("TRS-server-function");
|
m_passport.m_function_name = req.get_header_value("TRS-server-function");
|
||||||
if (m_passport.m_func_name.empty()) throw std::invalid_argument{ var::NO_VALID_DATA };
|
if (m_passport.m_function_name.empty()) throw std::invalid_argument{ var::NO_VALID_DATA };
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -26,11 +26,11 @@ namespace worckspaces
|
|||||||
|
|
||||||
auto main(int argc, char* args[]) -> int
|
auto main(int argc, char* args[]) -> int
|
||||||
{
|
{
|
||||||
trs::client cli {"localhost:5000", "token_auth"};
|
// trs::client cli {"localhost:5000", "token_auth"};
|
||||||
cli.post("/",trs::JSON{{ "test", "test message" }});
|
// cli.post("/",trs::JSON{{ "key", "test message" }});
|
||||||
|
|
||||||
// trs::server srv;
|
trs::server srv;
|
||||||
// srv.init("test service", "app_connection", "log_connection");
|
srv.init("test service", "app_connection", "log_connection");
|
||||||
// srv.registration("healthcheck", worckspaces::inspector, worckspaces::provider);
|
srv.registration("healthcheck", worckspaces::inspector, worckspaces::provider);
|
||||||
// srv.run();
|
srv.run();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user