mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added an another helper method to WebRouterNode.
This commit is contained in:
parent
bf7948be47
commit
7dc547b022
@ -33,6 +33,23 @@ bool WebRouterNode::try_route_request_to_children(Request *request) {
|
||||
return true;
|
||||
}
|
||||
|
||||
WebNode *WebRouterNode::get_request_handler_child(Request *request) {
|
||||
WebNode *handler = nullptr;
|
||||
|
||||
// if (path == "/") {
|
||||
if (request->get_path_segment_count() == 0) {
|
||||
// quick shortcut
|
||||
handler = _index_node;
|
||||
} else {
|
||||
const String &main_route = request->get_current_path_segment();
|
||||
handler = _node_route_map[main_route];
|
||||
|
||||
request->push_path();
|
||||
}
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
void WebRouterNode::build_handler_map() {
|
||||
_index_node = nullptr;
|
||||
_node_route_map.clear();
|
||||
|
@ -12,6 +12,7 @@ class WebRouterNode : public WebNode {
|
||||
public:
|
||||
void handle_request_main(Request *request);
|
||||
bool try_route_request_to_children(Request *request);
|
||||
WebNode *get_request_handler_child(Request *request);
|
||||
|
||||
void build_handler_map();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user