官术网_书友最值得收藏!

Level 2

Level 2 is for the use of HTTP verbs. So in level 1, we introduced resources, and level 2 introduces verbs.

Using the preceding example, when you post what you ate at 10 a.m., the server will give you back a resource. Using this resource, you can perform GET on that resource and see the details of what you ate at 10 a.m.:

    GET: diet/ate/12789 
    Response  
    { 
      'time':'10:00', 
      'apple':'1', 
      'water':'2' 
    } 

You can then update these details using PUT; note that we are acting on the same resource.

The request is as follows:

    PUT: diet/ate/12789 
    { 
      'time':'10:00', 
      'tea':'1', 
      'muffin':'3' 
    } 

You can also delete this resource if you realize later on that you didn't eat at 10 a.m.:

    DEL : diet/ate/12789 

We used the same resource with a different verb.

When we created the resource in level 1, we changed POST to return 201 when the resource is created and a 409 conflict if the resource exists.

Part of level 2 uses response codes and does not return 200 for every operation.

主站蜘蛛池模板: 凤山县| 噶尔县| 葫芦岛市| 巴里| 江油市| 岳阳县| 昭苏县| 定州市| 汤原县| 云阳县| 库尔勒市| 万荣县| 奉化市| 杨浦区| 丰台区| 芜湖县| 大英县| 会理县| 六盘水市| 岐山县| 景宁| 布尔津县| 名山县| 名山县| 石城县| 兰考县| 绥中县| 通渭县| 府谷县| 沈阳市| 广宗县| 独山县| 含山县| 滦南县| 高州市| 汾西县| 定陶县| 景宁| 龙游县| 永兴县| 迁安市|