接口 RouterFunction<T extends ServerResponse>

类型参数:
T - the type of the handler function to route to
所有已知实现类:
RouterFunctionBuilder.BuiltRouterFunction, RouterFunctions.AbstractRouterFunction, RouterFunctions.AttributesRouterFunction, RouterFunctions.DefaultNestedRouterFunction, RouterFunctions.DefaultRouterFunction, RouterFunctions.DifferentComposedRouterFunction, RouterFunctions.FilteredRouterFunction, RouterFunctions.ResourcesRouterFunction, RouterFunctions.SameComposedRouterFunction
函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

@FunctionalInterface public interface RouterFunction<T extends ServerResponse>
Represents a function that routes to a handler function.
从以下版本开始:
4.0
作者:
Arjen Poutsma, Harry Yang
另请参阅:
  • 方法详细资料

    • route

      Return the handler function that matches the given request.
      参数:
      request - the request to route
      返回:
      an Optional describing the HandlerFunction that matches this request, or an empty Optional 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.
      参数:
      other - the function of type T to apply when this function has no result
      返回:
      a composed function that first routes with this function and then the other function if this function has no result
      另请参阅:
    • 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.
      参数:
      other - the function to apply when this function has no result
      返回:
      a composed function that first routes with this function and then the other function if this function has no result
      另请参阅:
    • 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).
      参数:
      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
      返回:
      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).
      参数:
      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
      返回:
      a composed function that route to routerFunction if this route does not match and if predicate applies
    • filter

      default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T,S> filterFunction)
      Filter all handler functions routed by this function with the given filter function.
      类型参数:
      S - the filter return type
      参数:
      filterFunction - the filter to apply
      返回:
      the filtered routing function
    • accept

      default void accept(RouterFunctions.Visitor visitor)
      Accept the given visitor. Default implementation calls RouterFunctions.Visitor.unknown(RouterFunction); composed RouterFunction implementations are expected to call accept for all components that make up this router function.
      参数:
      visitor - the visitor to accept
    • withAttribute

      default RouterFunction<T> withAttribute(String name, Object value)
      Return a new routing function with the given attribute.
      参数:
      name - the attribute name
      value - the attribute value
      返回:
      a function that has the specified attributes
    • withAttributes

      default RouterFunction<T> withAttributes(Consumer<Map<String,Object>> attributesConsumer)
      Return a new routing function with attributes manipulated with the given consumer.

      The map provided to the consumer is "live", so that the consumer can be used to overwrite existing attributes, remove attributes, or use any of the other Map methods.

      参数:
      attributesConsumer - a function that consumes the attributes map
      返回:
      this builder