mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Removed static members from application.
This commit is contained in:
parent
614a496b7d
commit
8c483b4f8e
@ -22,7 +22,7 @@ void Application::setup_routes() {
|
||||
}
|
||||
|
||||
void Application::setup_middleware() {
|
||||
middlewares.push_back(HandlerInstance(Application::default_routing_middleware));
|
||||
middlewares.push_back(HandlerInstance([this](Object *instance, Request *request){ this->default_routing_middleware(instance, request); }));
|
||||
}
|
||||
|
||||
void Application::default_routing_middleware(Object *instance, Request *request) {
|
||||
@ -136,15 +136,5 @@ Application::~Application() {
|
||||
middlewares.clear();
|
||||
}
|
||||
|
||||
HandlerInstance Application::index_func;
|
||||
std::map<std::string, HandlerInstance> Application::main_route_map;
|
||||
std::vector<HandlerInstance> Application::middlewares;
|
||||
|
||||
std::map<int, std::function<void(int, Request *)> > Application::error_handler_map;
|
||||
std::function<void(int, Request *)> Application::default_error_handler_func = nullptr;
|
||||
|
||||
std::string Application::default_error_404_body = "<html><body>404 :(</body></html>";
|
||||
std::string Application::default_generic_error_body = "<html><body>Internal server error! :(</body></html>";
|
||||
|
||||
std::mutex Application::_update_registered_requests_mutex;
|
||||
std::vector<Request *> Application::_update_registered_requests;
|
||||
|
@ -18,9 +18,9 @@ public:
|
||||
static std::string default_error_404_body;
|
||||
static std::string default_generic_error_body;
|
||||
|
||||
static void handle_request(Request *request);
|
||||
static void send_error(int error_code, Request *request);
|
||||
static void send_file(const std::string &path, Request *request);
|
||||
void handle_request(Request *request);
|
||||
void send_error(int error_code, Request *request);
|
||||
void send_file(const std::string &path, Request *request);
|
||||
|
||||
static void default_fallback_error_handler(int error_code, Request *request);
|
||||
static void default_404_error_handler(int error_code, Request *request);
|
||||
@ -29,28 +29,28 @@ public:
|
||||
virtual void setup_routes();
|
||||
virtual void setup_middleware();
|
||||
|
||||
static void default_routing_middleware(Object *instance, Request *request);
|
||||
void default_routing_middleware(Object *instance, Request *request);
|
||||
|
||||
virtual void migrate();
|
||||
|
||||
static void register_request_update(Request *request);
|
||||
static void unregister_request_update(Request *request);
|
||||
static void update();
|
||||
void register_request_update(Request *request);
|
||||
void unregister_request_update(Request *request);
|
||||
void update();
|
||||
|
||||
Application();
|
||||
virtual ~Application();
|
||||
|
||||
public:
|
||||
static HandlerInstance index_func;
|
||||
static std::map<std::string, HandlerInstance> main_route_map;
|
||||
static std::vector<HandlerInstance> middlewares;
|
||||
HandlerInstance index_func;
|
||||
std::map<std::string, HandlerInstance> main_route_map;
|
||||
std::vector<HandlerInstance> middlewares;
|
||||
|
||||
static std::map<int, std::function<void(int, Request *)> > error_handler_map;
|
||||
static std::function<void(int, Request *)> default_error_handler_func;
|
||||
std::map<int, std::function<void(int, Request *)> > error_handler_map;
|
||||
std::function<void(int, Request *)> default_error_handler_func;
|
||||
|
||||
protected:
|
||||
static std::mutex _update_registered_requests_mutex;
|
||||
static std::vector<Request *> _update_registered_requests;
|
||||
std::mutex _update_registered_requests_mutex;
|
||||
std::vector<Request *> _update_registered_requests;
|
||||
};
|
||||
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
#define LOG_VERBOSE 0
|
||||
|
||||
void HTTPServer::http_callback_handler(Request *request) {
|
||||
Application::handle_request(request);
|
||||
application->handle_request(request);
|
||||
}
|
||||
|
||||
void HTTPServer::httpEnterCallbackDefault(const HTTPParser &httpParser, const HttpSession::Ptr &session) {
|
||||
|
@ -89,7 +89,7 @@ void Request::send_file(const std::string &p_file_path) {
|
||||
response->addHeadValue("Connection", "Close");
|
||||
std::string result = "HTTP/1.1 200 OK\r\nConnection: Close\r\n\r\n";
|
||||
|
||||
Application::register_request_update(this);
|
||||
application->register_request_update(this);
|
||||
|
||||
session->send(result.c_str(), result.size(), [this]() { this->_file_chunk_sent(); });
|
||||
}
|
||||
@ -233,7 +233,7 @@ void Request::_progress_send_file() {
|
||||
if (!f) {
|
||||
printf("Error: Download: In progress file doesn't exists anymore! %s\n", file_path.c_str());
|
||||
|
||||
Application::unregister_request_update(this);
|
||||
application->unregister_request_update(this);
|
||||
|
||||
session->postShutdown();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user