@Test public void addsExtraHeaders() { HttpInterceptor.Chain chain = request -> { assertThat(request.header("myRequestHeader").orElse(null), is("foo")); return Eventual.of(response(OK).build()); }; LiveHttpRequest request = get("/foo") .build(); LiveHttpResponse response = Mono.from(plugin.intercept(request, chain)).block(); assertThat(response.header("myResponseHeader").orElse(null), is("bar")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBuilder() .header("myResponseHeader", config.responseHeaderValue()) .build() ); }
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBuilder() .header("myResponseHeader", config.responseHeaderValue()) .build() ); } }
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBuilder() .header("myResponseHeader", config.responseHeaderValue()) .build() ); } ModifyHeadersExamplePlugin(ModifyHeadersExamplePluginConfig config); }
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBuilder() .header("myResponseHeader", config.responseHeaderValue()) .build() ); } ModifyHeadersExamplePlugin(ModifyHeadersExamplePluginConfig config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain); @Override Map<String, HttpHandler> adminInterfaceHandlers(); }
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBuilder() .header("myResponseHeader", config.responseHeaderValue()) .build() ); } ModifyHeadersExamplePlugin(ModifyHeadersExamplePluginConfig config); @Override Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain); @Override Map<String, HttpHandler> adminInterfaceHandlers();  }