Skip to content

Commit 2b0c9fa

Browse files
committed
Added README
1 parent e86720e commit 2b0c9fa

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<p align="center"><img src="https://raw.githubusercontent.com/JavaWebStack/docs/master/src/assets/img/icon.svg" width="100">
2+
<br><br>
3+
JavaWebStack HTTP-Client
4+
</p>
5+
6+
7+
8+
## A little tour
9+
Full documentations: [HTTP-Client JWS-Docs](https://javawebstack.org/docs/http-client)
10+
11+
```java
12+
HTTPClient client = new HTTPClient();
13+
14+
// Sending a simple GET-Request and printing the response-text
15+
System.out.println(client.get("https://example.javawebstack.org/api/test").string());
16+
17+
// Setting a base-url
18+
client.setBaseUrl("https://example.javawebstack.org"); // or new HTTPClient(baseUrl)
19+
20+
// Sending a POST-Request with a JSON-Body
21+
Map<String, Object> data = new HashMap<>();
22+
data.put("username", "password");
23+
24+
HTTPResponse res = client.post("/api/post")
25+
.jsonBody(data).json(User.class);
26+
```

src/main/java/org/javawebstack/httpclient/HTTPRequest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,8 @@ private static byte[] readAll(InputStream is) throws IOException {
177177
is.close();
178178
return baos.toByteArray();
179179
}
180+
181+
public String toString(){
182+
return string();
183+
}
180184
}

0 commit comments

Comments
 (0)