-
-
Save alganet/6430420 to your computer and use it in GitHub Desktop.
GET /products HTTP/1.1 | |
Host: example.com | |
HTTP/1.1 200 Ok | |
Content-Type: text/html;charset=utf-8 | |
<!doctype html> | |
<title>All Products</title> | |
<h1>Products</h1> | |
<ul> | |
<li><a rel="item" href="/products/1">Product 1</a></li> | |
<li><a rel="item" href="/products/2">Product 2</a></li> | |
<li><a rel="item" href="/products/3">Product 3</a></li> | |
<li><a rel="item" href="/products/4">Product 4</a></li> | |
</ul> | |
<form method=get action=/products> | |
<fieldset> | |
<legend>Filter products</legend> | |
<label>IDs separated by commas <input name=id value="1,4"/></label> | |
<button type=submit>Filter</button> | |
</fieldset> | |
</form> | |
<form method=post action=/products> | |
<fieldset> | |
<legend>New Product</legend> | |
<label>Name <input name="product[][name]"/></label> | |
<label>Yadda Text <input name="product[][yadda]"/></label> | |
<button type=submit>Create New Product</button> | |
</fieldset> | |
</form> |
GET /products?id=1,4 HTTP/1.1 | |
Host: example.com | |
HTTP/1.1 200 Ok | |
Content-Type: text/html;charset=utf-8 | |
<!doctype html> | |
<title>All Products</title> | |
<h1>Products</h1> | |
<ul> | |
<li><a rel="item" href="/products/1">Product 1</a></li> | |
<li><a rel="item" href="/products/4">Product 4</a></li> | |
</ul> | |
<form method=get action=/products> | |
<fieldset> | |
<legend>Filter products</legend> | |
<label>IDs separated by commas <input name=id value="1,4"/></label> | |
<button type=submit>Filter</button> | |
</fieldset> | |
</form> | |
<form method=post action=/products> | |
<fieldset> | |
<legend>New Product</legend> | |
<label>Name <input name="product[][name]"/></label> | |
<label>Yadda Text <input name="product[][yadda]"/></label> | |
<button type=submit>Create New Product</button> | |
</fieldset> | |
</form> |
GET /products/1 HTTP/1.1 | |
Host: example.com | |
HTTP/1.1 200 Ok | |
Content-Type: text/html;charset=utf-8 | |
<!doctype html> | |
<title>Product 1</title> | |
<h1>Product 1</h1> | |
<nav><a rel="parent collection" href="/products">All Products</a></nav> | |
<p>Product 1 yaddayadda</p> |
POST /products HTTP/1.1 | |
Host: example.com | |
Content-Type: multipart/formdata | |
product[][name]=Product 5& | |
product[][yadda]=Product yadda yadda yadda& | |
product[][name]=Product 6& | |
product[][yadda]=Product yadda yadda yaddayadda | |
HTTP/1.1 303 See Other | |
Location: /products?id=5,6 | |
POST /products?id=1,2 HTTP/1.1 | |
Host: example.com | |
Content-Type: multipart/formdata | |
yadda=Products 1 and 2 just yadda yadda yadda | |
HTTP/1.1 303 See Other | |
Location: /products?id=1,2 | |
POST /products?id=1 HTTP/1.1 | |
Host: example.com | |
Content-Type: multipart/formdata | |
yadda=Yadda for 1 now just yadda yadda | |
HTTP/1.1 303 See Other | |
Location: /products/1 | |
POST /products?id=1,4,5 HTTP/1.1 | |
Host: example.com | |
active=false | |
HTTP/1.1 200 No Content | |
Content-Type: text/html;charset=utf-8 | |
<!doctype html> | |
<title>No Products</title> | |
<h1>No Products</h1> | |
<form method=get action=/products> | |
<fieldset> | |
<legend>Filter products</legend> | |
<label>IDs separated by commas <input name=id value="1,4,5"/></label> | |
<button type=submit>Filter</button> | |
</fieldset> | |
</form> | |
<form method=post action=/products> | |
<fieldset> | |
<legend>New Product</legend> | |
<label>Name <input name="product[][name]"/></label> | |
<label>Yadda Text <input name="product[][yadda]"/></label> | |
<button type=submit>Create New Product</button> | |
</fieldset> | |
</form> | |
POST /products?id=1,4,5,20009 HTTP/1.1 | |
Host: example.com | |
active=false | |
HTTP/1.1 409 Conflict | |
Content-Type: text/html;charset=utf-8 | |
<!doctype html> | |
<title>Error Deleting Products</title> | |
<h1>Error Deleting Products</h1> | |
<form method=get action=/products> | |
<fieldset> | |
<legend>Deleting products</legend> | |
<p>The product with id 20009 could not be found. Please check the ID again and resubmit the form</p> | |
<label>IDs separated by commas <input name=id value="1,4,5,20009"/></label> | |
<button type=submit>Delete</button> | |
</fieldset> | |
</form> | |
</form> | |
I've changed for 200 =) 204 Means means that an operation on a resource has been successful and there is no content to display for that resource.
That is actually what happened on 07.http and 204 is semantically appropriate, the only problem is that by the spec a 204 should not return an entity body, so I've changed for 200.
I've also added a 08.http with an update for an item that doesn't exists on a collection.
Consider the following example :
PUT
/someresourcepath?condition=<logical_sentence>
In some cases I can need to make a request like this to transfer the same "state" to all resources that meet the «logical condition»
(in the request body is the representation of the new state to transfer for resources).
Is it right ? Any suggestions ?
@alganet If I want to move the "creation form" to its own page, which should be the URL?
On
07.http
I have always some doubts on what to do with the post result: