#pragma once #include #include #include "StaticFileHandler.H" #include "DynamicObjects.H" class DynamicObjects; class Routerin { public: //Routerin(StaticFileHandler &sfh); ~Routerin(); // const ??? static Routerin * get_instance() { static Routerin * me = nullptr; if (!me) return me = new Routerin(); return me; } static int event_route(struct mg_event *event) { // Foohash fh; Routerin *rouri = Routerin::get_instance(); switch (event->type) { case MG_REQUEST_BEGIN: return rouri->event_request_route(event); case MG_THREAD_BEGIN: return rouri->event_newthread_route(event); case MG_REQUEST_END: return rouri->event_requend_route(event); case MG_HTTP_ERROR: case MG_EVENT_LOG: case MG_THREAD_END: default: return rouri->event_fallback_route(event); } } std::string const & get_baseurl()const{return _baseurl;} void set_baseurl(std::string baseurl); private: explicit Routerin(); std::unique_ptr sfh; DynamicObjects * _dyn_obs; std::string _baseurl; bool hasInstance = false; int event_request_route ( struct mg_event *event); int event_newthread_route ( struct mg_event *event); int event_fallback_route ( struct mg_event *event); int event_requend_route ( struct mg_event *event); int rq_static(char const * const restrstr , struct mg_event *event); int rq_file(char const * const reststr , struct mg_event *event); int rq_date(char const * const reststr , struct mg_event *event); int rq_upload(char const * const reststr , struct mg_event *event); int rq_render_mainpage(struct mg_event *event); };