Split handle_request_main into handle_request_main and _handle_request_main. _handle_request_main should be responsible for actually rendering a page, while the normal one is responsible for routing by default. This makes the design simpler.

This commit is contained in:
Relintai 2022-01-09 18:35:12 +01:00
parent 0c6c20bd64
commit f498628ee1
3 changed files with 7 additions and 1 deletions

View File

@ -70,6 +70,11 @@ void WebNode::set_database(Database *db) {
#endif #endif
void WebNode::handle_request_main(Request *request) { void WebNode::handle_request_main(Request *request) {
_handle_request_main(request);
}
void WebNode::_handle_request_main(Request *request) {
request->send_error(HTTP_STATUS_CODE_404_NOT_FOUND);
} }
void WebNode::handle_error_send_request(Request *request, const int error_code) { void WebNode::handle_error_send_request(Request *request, const int error_code) {

View File

@ -33,6 +33,7 @@ public:
#endif #endif
virtual void handle_request_main(Request *request); virtual void handle_request_main(Request *request);
virtual void _handle_request_main(Request *request);
virtual void handle_error_send_request(Request *request, const int error_code); virtual void handle_error_send_request(Request *request, const int error_code);
virtual void create_validators(); virtual void create_validators();

View File

@ -5,7 +5,7 @@
void WebRouterNode::handle_request_main(Request *request) { void WebRouterNode::handle_request_main(Request *request) {
if (!try_route_request_to_children(request)) { if (!try_route_request_to_children(request)) {
request->send_error(404); _handle_request_main(request);
} }
} }