BAEL-3007: WebClient vs RestTemplate example.

This commit is contained in:
drazen
2019-07-18 20:23:15 +02:00
parent 01a447d6d3
commit 04e9fdafa4
9 changed files with 221 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package com.baeldung.webclient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
@RestController
public class TweetsSlowServiceController {
@GetMapping("/slow-service-tweets")
private List<Tweet> getAllTweets() throws Exception {
Thread.sleep(2000L); // delay
return Arrays.asList(
new Tweet("RestTemplate rules", "@user1"),
new Tweet("WebClient is better", "@user2"),
new Tweet("OK, both are useful", "@user1"));
}
}