public function handle(MinorRequest $minorRequest) { $this->minorRequest = $minorRequest; $this->minorResponse = MinorResponse::getInstance(); list($controllerName, $actionName, $params) = $this->router->dispatcher($this->minorRequest->getUrl()); if (!($controllerName && $actionName && is_array($params))) { if (!Config::get(['app' => 'DEBUG']) && ($handler = Config::get(['app' => '404_HANDLER'])) && $handler instanceof \Closure) { $handler($minorRequest->getRequestUrl()); } else { throw new AppException('404 Not Found'); } } else { $res = $this->invoke($controllerName, $actionName, $params); $res === $this->minorResponse ? $this->minorResponse = $res : $this->minorResponse->appendContent($res); } return $this->minorResponse; }
public function post($key, $default = '') { if (isset($this->postParams[$key])) { $defaultFilter = Config::get(['app' => 'DEFAULT_FILTER']); if ($defaultFilter) { if (is_string($defaultFilter)) { if (!function_exists($defaultFilter)) { throw new ConfigException('配置文件[app.php]:配置项[DEFAULT_FILTER]函数[' . $defaultFilter . ']不存在'); } return $defaultFilter($this->postParams[$key]); } if (!$defaultFilter instanceof \Closure) { throw new ConfigException('配置文件[app.php]:配置项[DEFAULT_FILTER]必须为字符串或匿名函数'); } return $defaultFilter($this->postParams[$key]); } return $this->postParams[$key]; } return $default; }