Created
May 11, 2017 17:01
-
-
Save moelholm/2e0346792c891dcccf8d2450d49680e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import org.springframework.http.MediaType; | |
import org.springframework.http.client.reactive.ReactorClientHttpConnector; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.web.client.reactive.WebClient; | |
import reactor.core.publisher.Mono; | |
import static org.springframework.web.client.reactive.ClientWebRequestBuilders.get; | |
import static org.springframework.web.client.reactive.ResponseExtractors.body; | |
@RestController | |
public class ReactiveController { | |
@RequestMapping("/reactive-controller") | |
public Mono<String> sayHello() { | |
WebClient reactiveHttpClient = new WebClient(new ReactorClientHttpConnector()); | |
return reactiveHttpClient | |
.perform(get("http://localhost:8080/traditional-controller").accept(MediaType.TEXT_PLAIN)) | |
.extract(body(String.class)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment