/** * Validate a given rule against a route and request. * * @param \Illuminate\Routing\Route $route * @param \Illuminate\Http\Request $request * @return bool */ public function matches(base_routing_route $route, base_http_request $request) { if (is_null($route->getCompiled()->getHostRegex())) { return true; } return preg_match($route->getCompiled()->getHostRegex(), $request->getHost()); }
/** * Validate a given rule against a route and request. * * @param \Illuminate\Routing\Route $route * @param \Illuminate\Http\Request $request * @return bool */ public function matches(base_routing_route $route, base_http_request $request) { if ($route->httpOnly()) { return !$request->secure(); } elseif ($route->secure()) { return $request->secure(); } return true; }
protected static function getFacadeAccessor() { if (!static::$__request) { // todo: 因为没有容器的临时策略 if (defined('WEB_MODE') && constant('WEB_MODE') === true) { static::$__request = base_http_request::createFromGlobals(); } else { $i = 'index.php'; $url = trim(config::get('app.url', 'http://localhost'), '/'); $url = strpos($url, $i) === false ? $url . '/' : $url; $parsed_url = parse_url($url); $path = $parsed_url['path']; $_SERVER['SCRIPT_FILENAME'] = PUBLIC_DIR . '/' . $i; $_SERVER['SCRIPT_NAME'] = (str_contains($path, $i) ? str_replace('/' . $i, '', $path) : $path) . '/' . $i; static::$__request = base_http_request::create($url, 'GET', [], [], [], $_SERVER); } } return static::$__request; }
/** * Validate a given rule against a route and request. * * @param \Illuminate\Routing\Route $route * @param \Illuminate\Http\Request $request * @return bool */ public function matches(base_routing_route $route, base_http_request $request) { $path = $request->path() == '/' ? '/' : '/' . $request->path(); return preg_match($route->getCompiled()->getRegex(), rawurldecode($path)); }
/** * Extract the parameter list from the host part of the request. * * @param request $request * @param array $parameters * @return array */ protected function bindHostParameters(Request $request, $parameters) { preg_match($this->compiled->getHostRegex(), $request->getHost(), $matches); return array_merge($this->matchToKeys(array_slice($matches, 1)), $parameters); }
/** * Validate a given rule against a route and request. * * @param \Illuminate\Routing\Route $route * @param \Illuminate\Http\Request $request * @return bool */ public function matches(base_routing_route $route, base_http_request $request) { return in_array($request->getMethod(), $route->methods()); }