File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
src/main/java/org/javawebstack/httpclient Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments