diff --git a/src/MediocreSimpleStaticFileHandler.cc b/src/MediocreSimpleStaticFileHandler.cc index 0fe150b..fa129c5 100644 --- a/src/MediocreSimpleStaticFileHandler.cc +++ b/src/MediocreSimpleStaticFileHandler.cc @@ -4,7 +4,7 @@ std::string MediocreSimpleStaticFileHandler::cleanpath (const char * const path) { //adds no security at all - return std::string(path); + return "static/"+std::string(path); } int diff --git a/src/Routerin.H b/src/Routerin.H index 9de5359..9598a9d 100644 --- a/src/Routerin.H +++ b/src/Routerin.H @@ -3,7 +3,7 @@ #include #include -#include "StaticFileHandler.H" +#include "MediocreSimpleStaticFileHandler.H" class Routerin { @@ -40,8 +40,8 @@ public: } private: explicit Routerin(); - std::unique_ptr sfh; - //bool hasInstance = false; + std::unique_ptr sfh; + bool hasInstance = false; int event_request_route ( struct mg_event *event); int event_newthread_route ( struct mg_event *event); diff --git a/src/Routerin.cc b/src/Routerin.cc index cb8862b..caa26cf 100644 --- a/src/Routerin.cc +++ b/src/Routerin.cc @@ -6,15 +6,16 @@ using std::strcmp; #include "Foohash.H" #include "Routerin.H" -#include "StaticFileHandler.H" -#include "UltraSimpleStaticFileHandler.H" +//#include "StaticFileHandler.H" +//#include "UltraSimpleStaticFileHandler.H" + using std::cout; using std::endl; Routerin::Routerin(): - sfh( new UltraSimpleStaticFileHandler()) + sfh( new MediocreSimpleStaticFileHandler()) { cout << "Konstr Routering" << std::endl; } @@ -57,10 +58,12 @@ int Routerin::event_request_route(struct mg_event *event){ break; default: std::cerr << "fallback "; - retval = rq_static((pntrstr),event); + retval = rq_static("illegalurl.htm",event); }; }else{ std::cerr << "no blub! in " << __LINE__ << endl; + retval = rq_static("illegalurl.htm",event); + } } std::free(tmpstr); @@ -74,7 +77,6 @@ int Routerin::event_request_route(struct mg_event *event){ } - int Routerin::rq_static(char const * const reststr , struct mg_event *event) { std::cerr << " a static file is reqested!" << endl; diff --git a/src/UltraSimpleStaticFileHandler.cc b/src/UltraSimpleStaticFileHandler.cc index b41b991..8a34204 100644 --- a/src/UltraSimpleStaticFileHandler.cc +++ b/src/UltraSimpleStaticFileHandler.cc @@ -10,14 +10,12 @@ static const char * hello_world_html = u8R"HERE( -

Sharing is caring

Hello World!

It works

+

It seems like a working page has been served

)HERE"; diff --git a/src/sicmain.cc b/src/sicmain.cc index 7f45257..a200a2c 100644 --- a/src/sicmain.cc +++ b/src/sicmain.cc @@ -135,12 +135,14 @@ int main(int argc, char **argv) sa.sa_handler = signalhandler; sigaction(SIGINT, &sa ,nullptr); - MongooseHandler m(args_info.port_arg); + MongooseHandler *m = new MongooseHandler(args_info.port_arg); + if (!args_info.daemonize_flag) { while(1) getchar(); } + delete m; return 0; }