defaultMethod

当控制器方法不存在的时候的默认方法

1.7.3版本对NormalRoute做了些调整,首先先匹配Controller,如果找不到直接返回404,然后寻找Method,如果找不到则会执行defaultMethod方法。

我们默认提供了一个处理机制。

    /**
     * 当控制器方法不存在的时候的默认方法
     */
    public function defaultMethod()
    {
        if ($this->request_type == SwooleMarco::HTTP_REQUEST) {
            $this->http_output->set_header('HTTP/1.1', '404 Not Found');
            $template = $this->loader->view('server::error_404');
            $this->http_output->end($template->render());
        } else {
            throw new SwooleException('method not exist');
        }
    }

如果需要自定义请重写此方法。

results matching ""

    No results matching ""