Last active
December 22, 2015 06:19
-
-
Save alganet/6430420 to your computer and use it in GitHub Desktop.
RESTful HTTP Containers. 01 - A GET on a container. 02 - A specific GET on a container with a filter (defined by the stateless forms in the request before). 03 - A GET on an item (defined by stateless links of the request before).
04 - A POST to create two new items (or any ammount, defined by the forms in requests before). 05 - A POST to update…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ?