FrameOptionsMiddleware extends AbstractWebMiddleware<HttpRequest, NRES> { @Override public HttpResponse handle(HttpRequest request, MiddlewareChain<HttpRequest, NRES, ?, ?> chain) { String headerValue = formatFrameOptions(); HttpResponse response = castToHttpResponse(chain.next(request)); HttpResponseUtils.header(response, "X-Frame-Options", headerValue); return response; } FrameOptionsMiddleware(); @Override HttpResponse handle(HttpRequest request, MiddlewareChain<HttpRequest, NRES, ?, ?> chain); void setFrameOptions(String frameOptions); void setFrameOptions(Parameters frameOptions);  }
@Test void defaultValueIsSameOrigin() { MiddlewareChain<HttpRequest, HttpResponse, ?, ?> chain = new DefaultMiddlewareChain<>(new AnyPredicate<>(), null, (Endpoint<HttpRequest, HttpResponse>) req -> builder(HttpResponse.of("hello")) .set(HttpResponse::setHeaders, Headers.of("Content-Type", "text/html")) .build()); HttpResponse response = middleware.handle(request, chain); assertThat(response.getHeaders().get("X-Frame-Options")).isEqualTo("SAMEORIGIN"); }