コード例 #1
0
ファイル: Rule.php プロジェクト: pinepain/ape
 public function isSecurityPolicyMatched(Request $request)
 {
     if (isset($this->arguments['secure']) && $this->arguments['secure'] !== null) {
         return $this->arguments['secure'] == $request->secure();
     }
     return true;
 }
コード例 #2
0
ファイル: Application.php プロジェクト: pinepain/ape
 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;
 }
コード例 #3
0
ファイル: Request.php プロジェクト: pinepain/ape
 /**
  * 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);
 }
コード例 #4
0
ファイル: Input.php プロジェクト: pinepain/ape
 /**
  * Replace the input for the current request.
  *
  * @param  array $input
  *
  * @return void
  */
 public static function replace(array $input)
 {
     return \Ape\Request::replace($input);
 }