<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 5.9 RESTful MSF 原生支持RESTful風格api,提供GET/POST/PUT/PATCH/HEAD/OPTIONS/DELETE動作的支持。 ### RESTful參考 * [理解 RESTful 架構](http://www.ruanyifeng.com/blog/2011/09/restful.html) * [RESTful API 設計指南](http://www.ruanyifeng.com/blog/2014/05/restful_api.html?from=timeline&isappinstalled=0) * [從消費者的角度評估 REST 的價值](http://hippoom.github.io/blogs/value-of-hypermedia-from-client-perspective.html) ### verb 介紹 ``` 'GET', // 從服務器取出資源(一項或多項) 'POST', // 在服務器新建一個資源 'PUT', // 在服務器更新資源(客戶端提供改變后的完整資源) 'PATCH', // 在服務器更新資源(客戶端提供改變的屬性) 'DELETE', // 從服務器刪除資源 'HEAD', // 獲取 head 元數據 'OPTIONS', // 獲取信息,關于資源的哪些屬性是客戶端可以改變的 ``` ### MSF實現RESTful程序 ``` Rest |- Controller.php 控制器 |- Route.php 路由器 ``` ### 使用方式 1. 在配置文件中配置路由器為: `$config['server']['route_tool'] = '\\PG\\MSF\\Route\\RestRoute'` 1. 配置URL路由規則 1. 控制器繼承 `PG\MSF\Rest\Controller` ### 推薦控制器接收不同動作映射 ``` 'PUT,PATCH {id}' => 'update', // 更新資源,如:/users/<id> 'DELETE {id}' => 'delete', // 刪除資源,如:/users/<id> 'GET,HEAD {id}' => 'view', // 查看資源單條數據,如:/users/<id> 'POST' => 'create', // 新建資源,如:/users 'GET,HEAD' => 'index', // 查看資源列表數據(可分頁),如:/users '{id}' => 'options', // 查看資源所支持的HTTP動詞,如:/users/<id> | /users '' => 'options', ``` ### URL路由配置 通過請求url中的path和動作類型即可路由到對應控制器下的某個方法(method)。URL路由配置支持正則方式,在url的path中可攜帶參數。例如: ``` $config['rest']['route']['rules'] = [ 'GET,POST /groups' => '/account/profile', 'GET /users/ask' => 'user/apply', 'GET /users' => 'user/index', 'GET /users/<uid:\d+>' => 'user/view', 'PUT /users/<method:\w+>' => 'user/<method>', 'DELETE /users/<uid:\d+>' => 'user/delete', ] ``` ### 響應 在控制器中使用 `$this->output(<params>,); `即可; ### 狀態碼 狀態碼只能是標準的http狀態碼,所有狀態碼見 `\PG\MSF\Base\Output::$codes` 5.10 多語言
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看