Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.function

public abstract Class RouterFunctions

extends Object
Class Inheritance
Imports
java.util.Collections, .LinkedHashMap, .Map, .Optional, java.util.function.BiConsumer, .BiFunction, .Consumer, .Function, .Predicate, .Supplier, org.apache.commons.logging.Log, .LogFactory, org.springframework.core.io.Resource, org.springframework.http.HttpHeaders, org.springframework.util.Assert, org.springframework.web.util.pattern.PathPatternParser

Central entry point to Spring's functional web framework. Exposes routing functionality, such as to create a RouterFunction using a discoverable builder-style API, to create a RouterFunction given a RequestPredicate and HandlerFunction, and to do further subrouting on an existing routing function.
Authors
Arjen Poutsma, Sebastien Deleuze
Since
5.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract static class
pack-priv static class
public static interface
RouterFunctions.Builder

Represents a discoverable builder for router functions.

private static class
private static class
pack-priv static class
RouterFunctions.DifferentComposedRouterFunction

A composed routing function that first invokes one function, and then invokes another function (of a different response type) if this route had no result.

pack-priv static class
RouterFunctions.FilteredRouterFunction<
the type of the handler function to filter
T extends ServerResponse
,
the type of the response of the function
S extends ServerResponse
>

Filter the specified handler functions with the given filter function.

private static class
pack-priv static class
RouterFunctions.SameComposedRouterFunction<
the server response type
T extends ServerResponse
>

A composed routing function that first invokes one function, and then invokes the another function (of the same response type T) if this route had no result.

public static interface
RouterFunctions.Visitor

Receives notifications from the logical structure of router functions.

Field Summary

Modifier and TypeField and Description
private static final Log
public static final String
MATCHING_PATTERN_ATTRIBUTE

Name of the request attribute that contains the matching pattern, as a org.springframework.web.util.pattern.PathPattern.

public static final String
REQUEST_ATTRIBUTE

Name of the request attribute that contains the ServerRequest.

public static final String
URI_TEMPLATE_VARIABLES_ATTRIBUTE

Name of the request attribute that contains the URI templates map, mapping variable names to values.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
the type of response returned by the handler function
T extends ServerResponse
>
RouterFunction<T>

Returns:

the change router function
changeParser
(RouterFunction<T>
the router function to change the parser in
routerFunction
,
PathPatternParser
the parser to change to.
parser
)

Changes the PathPatternParser on the given router function.

public static <
the type of response returned by the handler function
T extends ServerResponse
>
RouterFunction<T>

Returns:

a router function that routes to routerFunction if predicate evaluates to true
nest
(RequestPredicate
the predicate to test
predicate
,
RouterFunction<T>
the nested router function to delegate to if the predicate applies
routerFunction
)

Route to the given router function if the given request predicate applies.

public static RouterFunction<ServerResponse>

Returns:

a router function that routes to a resource
resource
(RequestPredicate
predicate to match
predicate
,
Resource
the resources to serve
resource
)

Route requests that match the given predicate to the given resource.

public static RouterFunction<ServerResponse>

Returns:

a router function that routes to a resource
resource
(RequestPredicate
predicate to match
predicate
,
Resource
the resources to serve
resource
,
BiConsumer<Resource, HttpHeaders>
provides access to the HTTP headers for served resources
headersConsumer
)

Route requests that match the given predicate to the given resource.

public static Function<ServerRequest, Optional<Resource>>

Returns:

the default resource lookup function for the given parameters.
resourceLookupFunction
(String
the pattern to match
pattern
,
Resource
the location directory relative to which resources should be resolved
location
)

Returns the resource lookup function used by resources(String, Resource).

public static RouterFunction<ServerResponse>

Returns:

a router function that routes to resources
resources
(String
the pattern to match
pattern
,
Resource
the location directory relative to which resources should be resolved
location
)

Route requests that match the given pattern to resources relative to the given root location.

public static RouterFunction<ServerResponse>

Returns:

a router function that routes to resources
resources
(String
the pattern to match
pattern
,
Resource
the location directory relative to which resources should be resolved
location
,
BiConsumer<Resource, HttpHeaders>
provides access to the HTTP headers for served resources
headersConsumer
)

Route requests that match the given pattern to resources relative to the given root location.

public static RouterFunction<ServerResponse>

Returns:

a router function that routes to resources
resources
(Function<ServerRequest, Optional<Resource>>
the function to provide a Resource given the ServerRequest
lookupFunction
)

Route to resources using the provided lookup function.

public static RouterFunction<ServerResponse>

Returns:

a router function that routes to resources
resources
(Function<ServerRequest, Optional<Resource>>
the function to provide a Resource given the ServerRequest
lookupFunction
,
BiConsumer<Resource, HttpHeaders>
provides access to the HTTP headers for served resources
headersConsumer
)

Route to resources using the provided lookup function.

public static RouterFunctions.Builder

Returns:

a router function builder
route
()

Offers a discoverable way to create router functions through a builder-style interface.

public static <
the type of response returned by the handler function
T extends ServerResponse
>
RouterFunction<T>

Returns:

a router function that routes to handlerFunction if predicate evaluates to true
route
(RequestPredicate
the predicate to test
predicate
,
HandlerFunction<T>
the handler function to route to if the predicate applies
handlerFunction
)

Route to the given handler function if the given request predicate applies.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait