@Test public void modifiesContent() { Config config = new Config("MyExtraText"); ModifyContentByAggregationExamplePlugin plugin = new ModifyContentByAggregationExamplePlugin(config); LiveHttpRequest request = get("/").build(); HttpInterceptor.Chain chain = anyRequest -> Eventual.of(response() .body("OriginalBody", UTF_8) .build() .stream()); HttpResponse response = Mono.from(plugin.intercept(request, chain) .flatMap(liveResponse -> liveResponse.aggregate(100))) .block(); assertThat(response.bodyAs(UTF_8), is("OriginalBodyMyExtraText")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .body(body + config.extraText(), UTF_8) .build(); }) .map(HttpResponse::stream); }
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .body(body + config.extraText(), UTF_8) .build(); }) .map(HttpResponse::stream); } }
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .body(body + config.extraText(), UTF_8) .build(); }) .map(HttpResponse::stream); } ModifyContentByAggregationExamplePlugin(Config config); }
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .body(body + config.extraText(), UTF_8) .build(); }) .map(HttpResponse::stream); } ModifyContentByAggregationExamplePlugin(Config config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain); }
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .body(body + config.extraText(), UTF_8) .build(); }) .map(HttpResponse::stream); } ModifyContentByAggregationExamplePlugin(Config config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain);  }