mege JSON-103 into default. #close JSON-103

JSON-108
Roker 5 years ago
commit ffbacecf3e

@ -124,6 +124,7 @@ struct JsonAdapter::Internal
bool running = false;
bool silent = false;
bool ignore_session_error = false;
bool deliver_html = true;
ThreadPool threads;
PEP_SESSION session = nullptr;
@ -525,6 +526,7 @@ JsonAdapter& JsonAdapter::do_sync(bool _do_sync)
return *this;
}
JsonAdapter& JsonAdapter::ignore_session_errors(bool _ig)
{
check_guard();
@ -533,6 +535,13 @@ JsonAdapter& JsonAdapter::ignore_session_errors(bool _ig)
}
JsonAdapter& JsonAdapter::deliver_html(bool dh)
{
check_guard();
i->deliver_html = dh;
return *this;
}
void JsonAdapter::prepare_run(const std::string& address, unsigned start_port, unsigned end_port)
{
@ -626,8 +635,12 @@ void JsonAdapter::threadFunc()
throw std::runtime_error("Failed to create new evhttp.");
evhttp_set_cb(evHttp.get(), ApiRequestUrl.c_str() , ev_server::OnApiRequest , this);
evhttp_set_cb(evHttp.get(), "/pep_functions.js" , ev_server::OnGetFunctions , this);
evhttp_set_gencb(evHttp.get(), ev_server::OnOtherRequest, nullptr);
if(i->deliver_html)
{
evhttp_set_cb(evHttp.get(), "/pep_functions.js" , ev_server::OnGetFunctions , this);
evhttp_set_gencb(evHttp.get(), ev_server::OnOtherRequest, nullptr);
}
if (i->sock == -1) // no port bound, yet
{

@ -32,6 +32,9 @@ public:
JsonAdapter& do_sync(bool _do_sync);
JsonAdapter& ignore_session_errors(bool _ig);
// if called with "false" the JSON Adpapter would no longer deliver HTML and JavaScript files, only handle JSON-RPC requests
JsonAdapter& deliver_html(bool _deliver_html);
// look for a free port to listen on
void prepare_run(const std::string& address, unsigned start_port, unsigned end_port);

@ -19,6 +19,7 @@ bool debug_mode = false;
bool do_sync = false;
bool ignore_missing_session = false;
bool add_sharks = false;
bool no_html = false;
uintptr_t status_handle = 0;
@ -61,6 +62,7 @@ try
("logfile,l", po::value<std::string>(&logfile)->default_value(logfile), "Name of the logfile. Can be \"stderr\" for log to stderr or empty for no log.")
("ignore-missing-session", po::bool_switch(&ignore_missing_session), "Ignore when no PEP_SESSION can be created.")
("add-sharks", po::bool_switch(&add_sharks), "Add sharks to the JSON Adapter.")
("no-html" , po::bool_switch(&no_html ), "Don't deliver HTML and JavaScript files, only accept JSON-RPC calls.")
#ifdef _WIN32
((STATUS_HANDLE), po::value<uintptr_t>(&status_handle)->default_value(0), "Status file handle, for internal use.")
#endif
@ -125,6 +127,7 @@ try
JsonAdapter ja;
ja.do_sync( do_sync)
.ignore_session_errors( ignore_missing_session)
.deliver_html( !no_html )
;
/*
* FIXME: why are exceptions risen after the instantiation of JsonAdapter

Loading…
Cancel
Save