Moved get_server from WebRoot to WebNode.

This commit is contained in:
Relintai 2022-01-08 12:00:12 +01:00
parent f00e5c5c9e
commit d873312915
4 changed files with 18 additions and 20 deletions

View File

@ -1,10 +1,11 @@
#include "web_node.h"
#include "request.h"
#include "http_enums.h"
#include "request.h"
#include "core/settings/settings.h"
#include "core/http/web_server.h"
#ifdef DATABASES_ENABLED
#include "core/database/database.h"
@ -72,8 +73,8 @@ void WebNode::handle_request_main(Request *request) {
}
void WebNode::handle_error_send_request(Request *request, const int error_code) {
//this is a fallback error handler.
//Webroot implements a proper one
// this is a fallback error handler.
// Webroot implements a proper one
request->compiled_body = "<html><body>Internal server error!</body></html>";
request->set_status_code(HTTP_STATUS_CODE_503_SERVICE_UNAVAILABLE);
request->send();
@ -94,6 +95,11 @@ void WebNode::migrate() {
void WebNode::create_default_entries() {
}
WebServer *WebNode::get_server() {
// todo this shoult probably be cached
return Object::cast_to<WebServer>(get_tree());
}
WebNode::WebNode() :
Node() {
// should look this up in parents when parented (and node parenting is implemented)

View File

@ -7,6 +7,7 @@
class Request;
class Settings;
class WebServer;
#ifdef DATABASES_ENABLED
class DataBase;
@ -41,6 +42,8 @@ public:
virtual void migrate();
virtual void create_default_entries();
WebServer *get_server();
WebNode();
~WebNode();

View File

@ -12,8 +12,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "core/http/web_server.h"
void WebRoot::load_settings() {
}
@ -165,11 +163,6 @@ void WebRoot::update() {
}
}
WebServer *WebRoot::get_server() {
// todo this shoult probably be cached
return Object::cast_to<WebServer>(get_tree());
}
WebRoot::WebRoot() :
WebRouterNode() {
}

View File

@ -12,21 +12,19 @@
#include "handler_instance.h"
class Request;
class WebServer;
//Middleware turn into a class (reference)
//add them to a folder
//method should return bool -> true to continue, false if done
//Error handlers
//Add to WebNode api -> send_error(code) v handle_error_send_request(request, int error, variant additional data ?);
//have generic one implemented by default
//Webroot overrides -> uses same logic as now
//notification -> variant additional data?
//FileCache -> set up, for this webroot, don't use singleton
//clean up unused things here
//remove handler instances!
//Update the rest of the modules to the new systems
class WebRoot : public WebRouterNode {
RCPP_OBJECT(WebRoot, WebRouterNode);
@ -56,8 +54,6 @@ public:
void unregister_request_update(Request *request);
void update();
WebServer *get_server();
WebRoot();
virtual ~WebRoot();