private function dispatch(Request $request) { $match = \Route::find($request->domain() . $request->path()); if (!$match) { // try to use fallback metcanism return false; } if (!$match->rule->isMethodAllowed($request)) { // return 405 Method Not Allowed return false; } if (!$match->rule->isSecurityPolicyMatched($request)) { // return 426 Upgrade Required (in fact, makes sense only from plain http -> tls switch) return false; } foreach ($match->rule->getBefore() as $callback) { $before_result = call_user_func(\Route::getFilter($callback), $request, $match); if ($before_result) { return $before_result; } } $action = $match->rule->getAction($request->method()); $with = $match->rule->getWith(); foreach ($match->matches as $name => $value) { $with[$name] = $value; } $callback = \resolve_callback($action, strtolower($request->method())); $result = call_user_func_array($callback, $with); foreach ($match->rule->getAfter() as $callback) { $after_result = call_user_func(\Route::getFilter($callback), $request, $result); if ($after_result) { return $after_result; } } return $result; }