package de.springbootbuch.reactive.client;

import java.util.Locale;
import java.util.concurrent.CountDownLatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * Part of springbootbuch.de.
 *
 * @author Michael J. Simons
 * @author @rotnroll666
 */
@SpringBootApplication
public class Application {

	static final Logger LOG = LoggerFactory
		.getLogger(Application.class);
	
	public static void main(String[] args) throws InterruptedException {
		SpringApplication.run(Application.class, args);
		
		final CountDownLatch closeLatch = new CountDownLatch(1);
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				closeLatch.countDown();
			}
		});
		closeLatch.await();
	}

	@Bean
	WebClient webClient() {
		return WebClient.create("http://localhost:8080/api");
	}

	@Bean
	CommandLineRunner streamingClient(WebClient client) {
		return args -> 
			client
				.get().uri("/films")
				.retrieve().bodyToFlux(Film.class)
				.filter(film -> 
					film.getTitle().toLowerCase(Locale.GERMAN)
						.contains("goldfinger"))
				.flatMap(film -> 
					client.get()
					.uri("/films/{id}/stream", film.getId())
					.retrieve()
					.bodyToFlux(Film.class))
				.subscribe(film -> 
					LOG.info("Streaming {}...", film.getTitle())
				);
	}
}

@@ -386,16 +386,124 @@
 n.Bean;%0A
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;%0A
 import o
@@ -1170,16 +1170,20 @@
 ebClient
+%0A%09%09%09
 .create(
@@ -1210,16 +1210,66 @@
 80/api%22)
+%0A%09%09%09.filter(basicAuthentication(%22spring%22, %22boot%22))
 ;%0A%09%7D%0A%0A%09@

Configure Client to use security