src/Http/Router.php
private function parseBy($rules, Request $request) {
		foreach ($rules as $rewrite) {
			if (isset($rewrite['uri'])) {
				if ($request->uri === $rewrite['uri']) {
					$dispatch = $rewrite['dispatch'];
					break;
				}
			} else {
				if (preg_match($rewrite['regex'], $request->uri, $matches)) {
					$param = [];
					unset($matches[0]);
					//参数
					foreach ($rewrite['param'] as $k => $v) {
						$param[$v] = $matches[$k + 1];
					}
					$dispatch = $rewrite['dispatch'];
					if ($dispatch instanceof \Closure) {
						$dispatch = $dispatch($param);
						if ($dispatch === null) {
							unset($dispatch);
							continue;
						}
					}
					break;
				}
			}
		}
		if (isset($dispatch)) {
			$request->module = isset($dispatch['module']) ? $dispatch['module'] : $this->module;
			$request->controller = $dispatch['controller'];
			$request->action = $dispatch['action'];
			if (isset($param)) {
				$request->param = $param;
			}
			return true;
		}
		return false;
	}
private function parseBy($rules, Request $request) {
		foreach ($rules as $rewrite) {
			if (isset($rewrite['uri'])) {
				if ($request->uri === $rewrite['uri']) {
					$dispatch = $rewrite['dispatch'];
					break;
				}
			} else {
				if (preg_match($rewrite['regex'], $request->uri, $matches)) {
					$param = [];
					unset($matches[0]);
					//参数
					foreach ($rewrite['param'] as $k => $v) {
						$param[$v] = $matches[$k + 1];
					}
					$dispatch = $rewrite['dispatch'];
					if ($dispatch instanceof \Closure) {
						$dispatch = $dispatch($param);
						if ($dispatch === null) {
							unset($dispatch);
							continue;
						}
					}
					break;
				}
			}
		}
		if (isset($dispatch)) {
			$request->module = isset($dispatch['module']) ? $dispatch['module'] : $this->module;
			$request->controller = $dispatch['controller'];
			$request->action = $dispatch['action'];
			if (isset($param)) {
				$request->param = $param;
			}
			return true;
		}
		return false;
	}
private function parseBy ( $ rules , Request $ request ) { foreach ( $ rules as $ rewrite ) { if ( isset ( $ rewrite [ 'uri' ] ) ) { if ( $ request -> uri === $ rewrite [ 'uri' ] ) { $ dispatch = $ rewrite [ 'dispatch' ] ; break ; } } else { if ( preg_match ( $ rewrite [ 'regex' ] , $ request -> uri , $ matches ) ) { $ param = [ ] ; unset ( $ matches [ 0 ] ) ; //参数 foreach ( $ rewrite [ 'param' ] as $ k => $ v ) { $ param [ $ v ] = $ matches [ $ k + 1 ] ; } $ dispatch = $ rewrite [ 'dispatch' ] ; if ( $ dispatch instanceof \ Closure ) { $ dispatch = $ dispatch ( $ param ) ; if ( $ dispatch === null ) { unset ( $ dispatch ) ; continue ; } } break ; } } } if ( isset ( $ dispatch ) ) { $ request -> module = isset ( $ dispatch [ 'module' ] ) ? $ dispatch [ 'module' ] : $ this -> module ; $ request -> controller = $ dispatch [ 'controller' ] ; $ request -> action = $ dispatch [ 'action' ] ; if ( isset ( $ param ) ) { $ request -> param = $ param ; } return true ; } return false ; }
Parse request with given rules

@access private
@param array $rules
@param Request $request
@return bool
Parse request with given rules