move impl from register_function and register_inspector to registration
This commit is contained in:
parent
f3bbf8f3a0
commit
5bec01b9df
@ -29,21 +29,19 @@ namespace trs
|
||||
set_idle_interval(0, 1'000'000);
|
||||
set_payload_max_length(1024 * 1024 * 512); // 512MB
|
||||
set_CORS();
|
||||
set_post();
|
||||
database::instance().set_connection(app_connection, log_connection);
|
||||
}
|
||||
|
||||
template<typename Key, typename Function>
|
||||
void register_function(Key func_name, Function func) { m_function_manager.register_function(func_name, func); }
|
||||
|
||||
template<typename Key, typename Function>
|
||||
void register_inspector(Key func_name, Function func) { m_inspector.register_function(func_name, func); }
|
||||
template<typename Function>
|
||||
void registration(std::string func_name, Function insp, Function func)
|
||||
{
|
||||
m_inspector.register_function(func_name, insp);
|
||||
m_function_manager.register_function(func_name, func);
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
// HERE
|
||||
// может в init перенести ???
|
||||
set_post();
|
||||
|
||||
try
|
||||
{
|
||||
hack::log(" ")("server listen:", var::HOST, var::PORT);
|
||||
|
@ -5,13 +5,6 @@
|
||||
|
||||
namespace worckspaces
|
||||
{
|
||||
inline void provider(trs::transaction& tr)
|
||||
{
|
||||
hack::log()("provider", tr.m_data.m_payload);
|
||||
tr.m_data.m_result["status"] = "ok";
|
||||
tr.m_data.m_result["result"] = "super ok";
|
||||
}
|
||||
|
||||
inline void inspector(trs::transaction& tr)
|
||||
{
|
||||
if (tr.m_data.m_payload.size() != 0)
|
||||
@ -23,14 +16,20 @@ namespace worckspaces
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
inline void provider(trs::transaction& tr)
|
||||
{
|
||||
hack::log()("provider", tr.m_data.m_payload);
|
||||
tr.m_data.m_result["status"] = "ok";
|
||||
tr.m_data.m_result["result"] = "super ok";
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char* args[]) -> int
|
||||
{
|
||||
trs::http app;
|
||||
app.register_function("healthcheck", worckspaces::provider);
|
||||
app.register_inspector("healthcheck", worckspaces::inspector);
|
||||
|
||||
app.init("app_connection", "log_connection");
|
||||
|
||||
app.registration("healthcheck", worckspaces::inspector, worckspaces::provider);
|
||||
app.run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user