public function isSecurityPolicyMatched(Request $request) { if (isset($this->arguments['secure']) && $this->arguments['secure'] !== null) { return $this->arguments['secure'] == $request->secure(); } return true; }
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; }
/** * Retrieve a cookie item from the request. * * @param string $key * @param mixed $default * * @return string|array|mixed */ public static function cookie($key = null, $default = null) { return \Ape\Request::cookie($key, $default); }
/** * Replace the input for the current request. * * @param array $input * * @return void */ public static function replace(array $input) { return \Ape\Request::replace($input); }