repos - Ce qui est exactement la programmation RESTful

Mots clés : resthttparchitecturedefinitionrest

meilleur 3 Réponses repos - Ce qui est exactement la programmation RESTful

vote vote

96

GET / Accept: application/json+userdb 
200 OK Content-Type: application/json+userdb  {     "version": "1.0",     "links": [         {             "href": "/user",             "rel": "list",             "method": "GET"         },         {             "href": "/user",             "rel": "create",             "method": "POST"         }     ] } 
GET /user Accept: application/json+userdb 
200 OK Content-Type: application/json+userdb  {     "users": [         {             "id": 1,             "name": "Emil",             "country: "Sweden",             "links": [                 {                     "href": "/user/1",                     "rel": "self",                     "method": "GET"                 },                 {                     "href": "/user/1",                     "rel": "edit",                     "method": "PUT"                 },                 {                     "href": "/user/1",                     "rel": "delete",                     "method": "DELETE"                 }             ]         },         {             "id": 2,             "name": "Adam",             "country: "Scotland",             "links": [                 {                     "href": "/user/2",                     "rel": "self",                     "method": "GET"                 },                 {                     "href": "/user/2",                     "rel": "edit",                     "method": "PUT"                 },                 {                     "href": "/user/2",                     "rel": "delete",                     "method": "DELETE"                 }             ]         }     ],     "links": [         {             "href": "/user",             "rel": "create",             "method": "POST"         }     ] } 
POST /user Accept: application/json+userdb Content-Type: application/json+userdb  {     "name": "Karl",     "country": "Austria" } 
201 Created Content-Type: application/json+userdb  {     "user": {         "id": 3,         "name": "Karl",         "country": "Austria",         "links": [             {                 "href": "/user/3",                 "rel": "self",                 "method": "GET"             },             {                 "href": "/user/3",                 "rel": "edit",                 "method": "PUT"             },             {                 "href": "/user/3",                 "rel": "delete",                 "method": "DELETE"             }         ]     },     "links": {        "href": "/user",        "rel": "list",        "method": "GET"     } } 
PUT /user/1 Accept: application/json+userdb Content-Type: application/json+userdb  {     "name": "Emil",     "country": "Bhutan" } 
200 OK Content-Type: application/json+userdb  {     "user": {         "id": 1,         "name": "Emil",         "country": "Bhutan",         "links": [             {                 "href": "/user/1",                 "rel": "self",                 "method": "GET"             },             {                 "href": "/user/1",                 "rel": "edit",                 "method": "PUT"             },             {                 "href": "/user/1",                 "rel": "delete",                 "method": "DELETE"             }         ]     },     "links": {        "href": "/user",        "rel": "list",        "method": "GET"     } } 
vote vote

89

http://myserver.com/catalog/item/1729 
http://myserver.com/catalog?item=1729 
http://myserver.com/addToCart?cart=314159&item=1729 
vote vote

75

POST /user fname=John&lname=Doe&age=25 
200 OK Location: /user/123 
GET /user/123 
200 OK <fname>John</fname><lname>Doe</lname><age>25</age> 
PATCH /user/123 fname=Johnny 
PUT /user/123 fname=Johnny 

Questions similaires