@Test public void replacesLiveContent() { ReplaceLiveContentExampleConfig config = new ReplaceLiveContentExampleConfig("myNewContent"); ReplaceLiveContentExamplePlugin plugin = new ReplaceLiveContentExamplePlugin(config); LiveHttpRequest request = get("/").build(); HttpInterceptor.Chain chain = request1 -> Eventual.of(LiveHttpResponse.response().build()); HttpResponse response = Mono.from(plugin.intercept(request, chain) .flatMap(liveResponse -> liveResponse.aggregate(100))) .block(); assertThat(response.bodyAs(UTF_8), is("myNewContent")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); }
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } }
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } ReplaceLiveContentExamplePlugin(ReplaceLiveContentExampleConfig config); }
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } ReplaceLiveContentExamplePlugin(ReplaceLiveContentExampleConfig config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain); }
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } ReplaceLiveContentExamplePlugin(ReplaceLiveContentExampleConfig config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain);  }