Example usage for org.springframework.web.reactive.function.server HandlerStrategies webFilters

List of usage examples for org.springframework.web.reactive.function.server HandlerStrategies webFilters

Introduction

In this page you can find the example usage for org.springframework.web.reactive.function.server HandlerStrategies webFilters.

Prototype

List<WebFilter> webFilters();

Source Link

Document

Return the WebFilter WebFilters to be used for filtering the request and response.

Usage

From source file:org.springframework.web.reactive.function.server.RouterFunctions.java

/**
 * Convert the given {@linkplain RouterFunction router function} into a {@link HttpHandler},
 * using the given strategies.//from www .  j  av a 2 s  .  co  m
 * <p>The returned {@code HttpHandler} can be adapted to run in
 * <ul>
 * <li>Servlet 3.1+ using the
 * {@link org.springframework.http.server.reactive.ServletHttpHandlerAdapter},</li>
 * <li>Reactor using the
 * {@link org.springframework.http.server.reactive.ReactorHttpHandlerAdapter},</li>
 * <li>Undertow using the
 * {@link org.springframework.http.server.reactive.UndertowHttpHandlerAdapter}.</li>
 * </ul>
 * @param routerFunction the router function to convert
 * @param strategies the strategies to use
 * @return an http handler that handles HTTP request using the given router function
 */
public static HttpHandler toHttpHandler(RouterFunction<?> routerFunction, HandlerStrategies strategies) {
    Assert.notNull(routerFunction, "RouterFunction must not be null");
    Assert.notNull(strategies, "HandlerStrategies must not be null");

    WebHandler webHandler = toWebHandler(routerFunction, strategies);
    return WebHttpHandlerBuilder.webHandler(webHandler)
            .filters(filters -> filters.addAll(strategies.webFilters()))
            .exceptionHandlers(handlers -> handlers.addAll(strategies.exceptionHandlers()))
            .localeContextResolver(strategies.localeContextResolver()).build();
}