src/Leevel/Router/Router.php
protected function pathinfoRestful(): void
    {
        if (!empty($this->matchedData[static::ACTION])) {
            return;
        }

        switch ($this->request->getMethod()) {
            // 跨域请求转发到首页
            // 防止由于 API 请求跨域提示路由不正确
            case 'OPTIONS':
                $this->matchedData[static::CONTROLLER] = static::DEFAULT_CONTROLLER;
                $this->matchedData[static::ACTION] = static::RESTFUL_INDEX;

                break;
            case 'POST':
                $this->matchedData[static::ACTION] = static::RESTFUL_STORE;

                break;
            case 'PUT':
                $this->matchedData[static::ACTION] = static::RESTFUL_UPDATE;

                break;
            case 'DELETE':
                $this->matchedData[static::ACTION] = static::RESTFUL_DESTROY;

                break;
            case 'GET':
            default:
                $params = $this->matchedParams();

                if (isset($params[static::RESTFUL_ID])) {
                    $this->matchedData[static::ACTION] = static::RESTFUL_SHOW;
                } else {
                    $this->matchedData[static::ACTION] = static::RESTFUL_INDEX;
                }

                break;
        }
    }
protected function pathinfoRestful(): void
    {
        if (!empty($this->matchedData[static::ACTION])) {
            return;
        }

        switch ($this->request->getMethod()) {
            // 跨域请求转发到首页
            // 防止由于 API 请求跨域提示路由不正确
            case 'OPTIONS':
                $this->matchedData[static::CONTROLLER] = static::DEFAULT_CONTROLLER;
                $this->matchedData[static::ACTION] = static::RESTFUL_INDEX;

                break;
            case 'POST':
                $this->matchedData[static::ACTION] = static::RESTFUL_STORE;

                break;
            case 'PUT':
                $this->matchedData[static::ACTION] = static::RESTFUL_UPDATE;

                break;
            case 'DELETE':
                $this->matchedData[static::ACTION] = static::RESTFUL_DESTROY;

                break;
            case 'GET':
            default:
                $params = $this->matchedParams();

                if (isset($params[static::RESTFUL_ID])) {
                    $this->matchedData[static::ACTION] = static::RESTFUL_SHOW;
                } else {
                    $this->matchedData[static::ACTION] = static::RESTFUL_INDEX;
                }

                break;
        }
    }
智能 restful 解析
路由匹配如果没有匹配上方法则系统会进入 restful 解析.