2022-01-07 16:36:39 +01:00
|
|
|
#ifndef WEB_NODE_H
|
|
|
|
#define WEB_NODE_H
|
|
|
|
|
2022-01-07 16:57:13 +01:00
|
|
|
#include "core/nodes/node.h"
|
2022-01-07 17:16:24 +01:00
|
|
|
#include "core/reference.h"
|
2022-01-08 11:47:39 +01:00
|
|
|
#include "core/variant.h"
|
2022-02-04 20:15:45 +01:00
|
|
|
#include <map>
|
2022-01-07 16:36:39 +01:00
|
|
|
|
|
|
|
class Request;
|
2022-01-07 17:16:24 +01:00
|
|
|
class Settings;
|
2022-01-08 12:00:12 +01:00
|
|
|
class WebServer;
|
2022-01-07 17:16:24 +01:00
|
|
|
|
|
|
|
#ifdef DATABASES_ENABLED
|
|
|
|
class DataBase;
|
|
|
|
class TableBuilder;
|
|
|
|
class QueryBuilder;
|
|
|
|
#endif
|
2022-01-07 16:36:39 +01:00
|
|
|
|
2022-01-07 16:57:13 +01:00
|
|
|
class WebNode : public Node {
|
2022-01-08 10:04:12 +01:00
|
|
|
RCPP_OBJECT(WebNode, Node);
|
|
|
|
|
2022-01-07 16:36:39 +01:00
|
|
|
public:
|
2022-01-08 10:50:07 +01:00
|
|
|
String get_uri_segment();
|
|
|
|
void set_uri_segment(const String &val);
|
|
|
|
|
2022-02-04 15:54:21 +01:00
|
|
|
virtual String get_full_uri(const bool slash_at_the_end = true);
|
|
|
|
virtual String get_full_uri_parent(const bool slash_at_the_end = true);
|
|
|
|
|
2022-01-07 17:16:24 +01:00
|
|
|
Settings *get_settings();
|
|
|
|
void set_settings(Settings *settings);
|
|
|
|
|
2022-02-04 20:18:52 +01:00
|
|
|
virtual bool get_routing_enabled();
|
|
|
|
virtual void set_routing_enabled(const bool value);
|
2022-02-04 20:15:45 +01:00
|
|
|
|
2022-01-07 17:16:24 +01:00
|
|
|
#ifdef DATABASES_ENABLED
|
|
|
|
Database *get_database();
|
|
|
|
Ref<TableBuilder> get_table_builder();
|
|
|
|
Ref<QueryBuilder> get_query_builder();
|
|
|
|
void set_database(Database *db);
|
|
|
|
#endif
|
|
|
|
|
2022-01-07 16:36:39 +01:00
|
|
|
virtual void handle_request_main(Request *request);
|
2022-01-09 18:35:12 +01:00
|
|
|
virtual void _handle_request_main(Request *request);
|
2022-01-08 11:47:39 +01:00
|
|
|
virtual void handle_error_send_request(Request *request, const int error_code);
|
2022-01-13 22:58:59 +01:00
|
|
|
virtual void render_menu(Request *request);
|
|
|
|
virtual void _render_menu(Request *request);
|
2022-01-08 11:47:39 +01:00
|
|
|
|
2022-01-07 16:36:39 +01:00
|
|
|
virtual void create_validators();
|
|
|
|
|
|
|
|
virtual void create_table();
|
|
|
|
virtual void drop_table();
|
2022-01-13 23:45:38 +01:00
|
|
|
virtual void udpate_table();
|
2022-01-07 17:02:47 +01:00
|
|
|
virtual void create_default_entries();
|
2022-01-07 16:36:39 +01:00
|
|
|
|
2022-01-13 23:45:38 +01:00
|
|
|
virtual void migrate(const bool clear, const bool seed);
|
|
|
|
virtual void _migrate(const bool clear, const bool seed);
|
|
|
|
|
2022-02-04 20:15:45 +01:00
|
|
|
bool try_route_request_to_children(Request *request);
|
|
|
|
WebNode *get_request_handler_child(Request *request);
|
|
|
|
void build_handler_map();
|
|
|
|
void clear_handlers();
|
|
|
|
|
2022-01-08 12:00:12 +01:00
|
|
|
WebServer *get_server();
|
2022-01-13 22:58:59 +01:00
|
|
|
WebNode *get_root();
|
2022-02-04 15:54:21 +01:00
|
|
|
WebNode *get_parent_webnode();
|
2022-01-08 12:00:12 +01:00
|
|
|
|
2022-02-04 20:15:45 +01:00
|
|
|
void _notification(const int what);
|
|
|
|
|
2022-01-07 16:36:39 +01:00
|
|
|
WebNode();
|
|
|
|
~WebNode();
|
|
|
|
|
|
|
|
protected:
|
2022-01-08 10:50:07 +01:00
|
|
|
String _uri_segment;
|
|
|
|
|
2022-01-07 17:16:24 +01:00
|
|
|
Settings *_settings;
|
|
|
|
|
|
|
|
#ifdef DATABASES_ENABLED
|
|
|
|
Database *_database;
|
|
|
|
#endif
|
2022-02-04 20:15:45 +01:00
|
|
|
|
|
|
|
bool _routing_enabled;
|
|
|
|
WebNode *_index_node;
|
|
|
|
std::map<String, WebNode *> _node_route_map;
|
2022-01-07 16:36:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|