mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Move middleware processing to a helper method.
This commit is contained in:
parent
7dc547b022
commit
d380d14152
@ -47,12 +47,7 @@ void WebRoot::default_404_error_handler(Request *request, int error_code) {
|
||||
}
|
||||
|
||||
void WebRoot::handle_request_main(Request *request) {
|
||||
for (int i = 0; i < _middlewares.size(); ++i) {
|
||||
if (_middlewares[i]->on_before_handle_request_main(request)) {
|
||||
//handled
|
||||
return;
|
||||
}
|
||||
}
|
||||
process_middlewares(request);
|
||||
|
||||
// handle files first
|
||||
if (try_send_wwwroot_file(request)) {
|
||||
@ -79,6 +74,15 @@ void WebRoot::handle_error_send_request(Request *request, const int error_code)
|
||||
func(request, error_code);
|
||||
}
|
||||
|
||||
void WebRoot::process_middlewares(Request *request) {
|
||||
for (int i = 0; i < _middlewares.size(); ++i) {
|
||||
if (_middlewares[i]->on_before_handle_request_main(request)) {
|
||||
// handled
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRoot::try_send_wwwroot_file(Request *request) {
|
||||
const String &path = request->get_path_full();
|
||||
|
||||
|
@ -25,6 +25,7 @@ public:
|
||||
void handle_request_main(Request *request);
|
||||
void handle_error_send_request(Request *request, const int error_code);
|
||||
|
||||
void process_middlewares(Request *request);
|
||||
bool try_send_wwwroot_file(Request *request);
|
||||
void send_file(const String &path, Request *request);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user