Skip to content

Commit

Permalink
Merge pull request #37 from emilesilvis/chore/examples
Browse files Browse the repository at this point in the history
chore: updated examples to use http://dummy.restapiexample.com
  • Loading branch information
shiffman authored Apr 23, 2021
2 parents 25ba69e + 1339621 commit f6f6119
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
17 changes: 9 additions & 8 deletions examples/delete/delete.pde
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import http.requests.*;

public void setup()
public void setup()
{
size(400,400);
smooth();

DeleteRequest delete = new DeleteRequest("http://httprocessing.heroku.com");
delete.send();
System.out.println("Reponse Content: " + delete.getContent());
System.out.println("Reponse Content-Length Header: " + delete.getHeader("Content-Length"));
size(400, 400);
smooth();

DeleteRequest delete = new DeleteRequest("http://dummy.restapiexample.com/api/v1/delete/971");
delete.addHeader("Content-Type", "application/json");
delete.send();
System.out.println("Reponse Content: " + delete.getContent());
System.out.println("Reponse Content-Length Header: " + delete.getHeader("Content-Length"));
}
6 changes: 3 additions & 3 deletions examples/get/get.pde
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import http.requests.*;

public void setup()
public void setup()
{
size(400,400);
smooth();
GetRequest get = new GetRequest("http://httprocessing.heroku.com");

GetRequest get = new GetRequest("http://dummy.restapiexample.com/api/v1/employees/1");
get.send();
println("Reponse Content: " + get.getContent());
println("Reponse Content-Length Header: " + get.getHeader("Content-Length"));
Expand Down
17 changes: 6 additions & 11 deletions examples/jsonget/jsonget.pde
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import http.requests.*;

public void setup()
public void setup()
{
size(400,400);
smooth();
GetRequest get = new GetRequest("http://connect.doodle3d.com/api/list.example");
size(400,400);
smooth();

GetRequest get = new GetRequest("http://dummy.restapiexample.com/api/v1/employees");
get.send(); // program will wait untill the request is completed
println("response: " + get.getContent());

JSONObject response = parseJSONObject(get.getContent());
println("status: " + response.getString("status"));
JSONArray boxes = response.getJSONArray("data");
println("boxes: ");
for(int i=0;i<boxes.size();i++) {
JSONObject box = boxes.getJSONObject(i);
println(" wifiboxid: " + box.getString("wifiboxid"));
}
println("data: " + response.getJSONArray("data"));
}
9 changes: 3 additions & 6 deletions examples/jsonpost/jsonpost.pde
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import http.requests.*;

public void setup()
{
public void setup() {
size(400, 400);
smooth();

PostRequest post = new PostRequest("http://httprocessing.heroku.com");
PostRequest post = new PostRequest("http://dummy.restapiexample.com/api/v1/create");
post.addHeader("Content-Type", "application/json");
post.addData("{\"on\":false}");
post.addData("{\"name\":\"Daniel Shiffman\",\"salary\":\"123\",\"age\":\"23\"}");
post.send();
System.out.println("Reponse Content: " + post.getContent());
System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
Expand Down
6 changes: 3 additions & 3 deletions examples/jsonput/jsonput.pde
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import http.requests.*;

public void setup()
public void setup()
{
size(400, 400);
smooth();

PutRequest put = new PutRequest("http://httprocessing.heroku.com");
PutRequest put = new PutRequest("http://dummy.restapiexample.com/api/v1/update/43");
put.addHeader("Content-Type", "application/json");
put.addData("{\"on\":false}");
put.addData("{\"name\":\"Daniel Shiffman\",\"salary\":\"1123\",\"age\":\"23\"}");
put.send();
System.out.println("Reponse Content: " + put.getContent());
System.out.println("Reponse Content-Length Header: " + put.getHeader("Content-Length"));
Expand Down

0 comments on commit f6f6119

Please sign in to comment.