org.springframework.web.reactive.function.server

Interface RouterFunction<T extends ServerResponse>

  • Type Parameters:
    T - the type of the handler function to route to
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.


    @FunctionalInterface
    public interface RouterFunction<T extends ServerResponse>
    Represents a function that routes to a handler function.
    Since:
    5.0
    Author:
    Arjen Poutsma
    See Also:
    RouterFunctions
    • Method Detail

      • route

        reactor.core.publisher.Mono<HandlerFunction<T>> route(ServerRequest request)
        Return the handler function that matches the given request.
        Parameters:
        request - the request to route
        Returns:
        an Mono describing the HandlerFunction that matches this request, or an empty Mono if there is no match
      • and

        default RouterFunction<T> and(RouterFunction<T> other)
        Return a composed routing function that first invokes this function, and then invokes the other function (of the same response type T) if this route had no result.
        Parameters:
        other - the function of type T to apply when this function has no result
        Returns:
        a composed function that first routes with this function and then the other function if this function has no result
        See Also:
        andOther(RouterFunction)
      • andOther

        default RouterFunction<?> andOther(RouterFunction<?> other)
        Return a composed routing function that first invokes this function, and then invokes the other function (of a different response type) if this route had no result.
        Parameters:
        other - the function to apply when this function has no result
        Returns:
        a composed function that first routes with this function and then the other function if this function has no result
        See Also:
        and(RouterFunction)
      • andRoute

        default RouterFunction<T> andRoute(RequestPredicate predicate,
                                           HandlerFunction<T> handlerFunction)
        Return a composed routing function that routes to the given handler function if this route does not match and the given request predicate applies. This method is a convenient combination of and(RouterFunction) and RouterFunctions.route(RequestPredicate, HandlerFunction).
        Parameters:
        predicate - the predicate to test if this route does not match
        handlerFunction - the handler function to route to if this route does not match and the predicate applies
        Returns:
        a composed function that route to handlerFunction if this route does not match and if predicate applies
      • andNest

        default RouterFunction<T> andNest(RequestPredicate predicate,
                                          RouterFunction<T> routerFunction)
        Return a composed routing function that routes to the given router function if this route does not match and the given request predicate applies. This method is a convenient combination of and(RouterFunction) and RouterFunctions.nest(RequestPredicate, RouterFunction).
        Parameters:
        predicate - the predicate to test if this route does not match
        routerFunction - the router function to route to if this route does not match and the predicate applies
        Returns:
        a composed function that route to routerFunction if this route does not match and if predicate applies