new struct of configuration paths

master
john stone 9 years ago
parent b181c1906b
commit 0cef450872

@ -44,17 +44,24 @@ public:
return rouri->event_fallback_route(event);
}
}
std::string const & get_baseurl()const{return _baseurl;}
std::string const & get_baseurl()const{return baseurl;}
void set_baseurl(std::string baseurl);
std::string const & get_file_path()const{return file_path;}
void set_file_path(std::string file_path);
std::string const & get_json_path()const{return json_path;}
void set_json_path(std::string json_path);
std::string const & get_persist_path() const { return perists_path;}
private:
explicit Routerin();
std::unique_ptr<StaticFileHandler> sfh;
DynamicObjects * _dyn_obs;
std::string _baseurl;
std::string baseurl;
std::string perists_path;
std::string file_path;
std::string json_path;
bool hasInstance = false;

@ -21,3 +21,7 @@ option "daemonize" D "Detach from calling terminal" flag off
option "dns" d "also start an dns fakeserver"
option "filedir" f "Directory for data storage. Musst be r/w able" string default="./files/"
option "janssons" j "Directory libjansson jasons db. Musst be r/w able" string default="./janssons/"
option "baseurl" b "Directory for data storage. Musst be r/w able" string default="/"

@ -24,19 +24,16 @@ class MongooseHandler{
public:
//default listenport:8080
MongooseHandler(int listenport=8080,std::string baseurl="http://[::1]/"):
MongooseHandler(int listenport=8080):
ctx(nullptr),
listenport(listenport)
{
char portstring[8];
Routerin *routerin = Routerin::get_instance();
routerin->set_baseurl(baseurl);
std::snprintf(portstring,8,"%d",this->listenport);
const char *options[] =
{"listening_ports",portstring,nullptr};
this->ctx= mg_start(options, routerin->event_route, nullptr);
this->ctx= mg_start(options, Routerin::event_route, nullptr);
}
//no copy constructor:
@ -139,9 +136,16 @@ int main(int argc, char **argv)
sa.sa_handler = signalhandler;
sigaction(SIGINT, &sa ,nullptr);
Routerin * merouterin = Routerin::get_instance();
merouterin->set_baseurl(args_info.baseurl_arg);
merouterin->set_json_path(args_info.janssons_arg);
merouterin->set_file_path(args_info.filedir_arg);
MongooseHandler *m = new MongooseHandler(args_info.port_arg);
if (!args_info.daemonize_flag) {
while(1)
getchar();

Loading…
Cancel
Save