src/Http/Router.php
public function parse(Request $request) {
		$len = strlen($this->prefix);
		//路由解析
		$uri = $request->server['request_uri'];
		if (strpos('?', $uri) !== false) {
			$uri = substr($uri, 0, strpos($uri, '?'));
		}
		//去除开头的prefix
		if ($len > 0 && strpos($uri, $this->prefix) === 0) {
			$uri = substr($uri, $len);
		}
		$request->uri = $uri;
		$res = false;
		if (isset($this->routes[$request->server['request_method']])) {
			$res = $this->parseBy($this->routes[$request->server['request_method']], $request);
		}
		if ($res === false && isset($this->routes['any'])) {
			$res = $this->parseBy($this->routes['any'], $request);
		}
		if ($res === false) {
			if ($this->enable_map) {
				//为空则读取默认设置
				if (empty($uri) || $uri === '/') {
					$request->module = $this->module;
					$request->controller = 'index';
					$request->action = 'index';
				} else {
					if ($this->enable_extension) {
						$hasPoint = strrpos($uri, '.');
						if ($hasPoint !== false) {
							$request->extension = substr($uri, $hasPoint + 1);
							$uri = substr($uri, 0, $hasPoint);
							$request->uri = $uri;
						}
					}
					$this->parseMap($request);
				}
			}
		}
	}
public function parse(Request $request) {
		$len = strlen($this->prefix);
		//路由解析
		$uri = $request->server['request_uri'];
		if (strpos('?', $uri) !== false) {
			$uri = substr($uri, 0, strpos($uri, '?'));
		}
		//去除开头的prefix
		if ($len > 0 && strpos($uri, $this->prefix) === 0) {
			$uri = substr($uri, $len);
		}
		$request->uri = $uri;
		$res = false;
		if (isset($this->routes[$request->server['request_method']])) {
			$res = $this->parseBy($this->routes[$request->server['request_method']], $request);
		}
		if ($res === false && isset($this->routes['any'])) {
			$res = $this->parseBy($this->routes['any'], $request);
		}
		if ($res === false) {
			if ($this->enable_map) {
				//为空则读取默认设置
				if (empty($uri) || $uri === '/') {
					$request->module = $this->module;
					$request->controller = 'index';
					$request->action = 'index';
				} else {
					if ($this->enable_extension) {
						$hasPoint = strrpos($uri, '.');
						if ($hasPoint !== false) {
							$request->extension = substr($uri, $hasPoint + 1);
							$uri = substr($uri, 0, $hasPoint);
							$request->uri = $uri;
						}
					}
					$this->parseMap($request);
				}
			}
		}
	}
public function parse ( Request $ request ) { $ len = strlen ( $ this -> prefix ) ; //路由解析 $ uri = $ request -> server [ 'request_uri' ] ; if ( strpos ( '?' , $ uri ) !== false ) { $ uri = substr ( $ uri , 0 , strpos ( $ uri , '?' ) ) ; } //去除开头的prefix if ( $ len > 0 && strpos ( $ uri , $ this -> prefix ) === 0 ) { $ uri = substr ( $ uri , $ len ) ; } $ request -> uri = $ uri ; $ res = false ; if ( isset ( $ this -> routes [ $ request -> server [ 'request_method' ] ] ) ) { $ res = $ this -> parseBy ( $ this -> routes [ $ request -> server [ 'request_method' ] ] , $ request ) ; } if ( $ res === false && isset ( $ this -> routes [ 'any' ] ) ) { $ res = $ this -> parseBy ( $ this -> routes [ 'any' ] , $ request ) ; } if ( $ res === false ) { if ( $ this -> enable_map ) { //为空则读取默认设置 if ( empty ( $ uri ) || $ uri === '/' ) { $ request -> module = $ this -> module ; $ request -> controller = 'index' ; $ request -> action = 'index' ; } else { if ( $ this -> enable_extension ) { $ hasPoint = strrpos ( $ uri , '.' ) ; if ( $ hasPoint !== false ) { $ request -> extension = substr ( $ uri , $ hasPoint + 1 ) ; $ uri = substr ( $ uri , 0 , $ hasPoint ) ; $ request -> uri = $ uri ; } } $ this -> parseMap ( $ request ) ; } } } }
Parse a request

@access public
@param Request $request
Parse a request