@Singleton @Requires(beans=RoutesVersioningConfiguration.class) public class RouteVersionFilter extends Object implements VersionRouteMatchFilter
RouteMatchFilter
responsible for filtering route matches on Version
.Constructor and Description |
---|
RouteVersionFilter(List<RequestVersionResolver> resolvingStrategies,
DefaultVersionProvider defaultVersionProvider)
Creates a
RouteVersionFilter with a collection of RequestVersionResolver . |
Modifier and Type | Method and Description |
---|---|
<T,R> Predicate<UriRouteMatch<T,R>> |
filter(HttpRequest<?> request)
Filters route matches by specified version.
|
protected <T,R> Optional<String> |
getVersion(UriRouteMatch<T,R> routeMatch) |
protected boolean |
matchIfRouteIsNotVersioned(HttpRequest<?> request,
String version) |
protected boolean |
matchIfRouteIsVersioned(HttpRequest<?> request,
String resolvedVersion,
String routeVersion) |
protected Optional<String> |
resolveVersion(HttpRequest<?> request) |
public RouteVersionFilter(List<RequestVersionResolver> resolvingStrategies, @Nullable DefaultVersionProvider defaultVersionProvider)
RouteVersionFilter
with a collection of RequestVersionResolver
.resolvingStrategies
- A list of RequestVersionResolver
beans to extract version from HTTP requestdefaultVersionProvider
- The Default Version Providerpublic <T,R> Predicate<UriRouteMatch<T,R>> filter(HttpRequest<?> request)
filter
in interface RouteMatchFilter
T
- The target typeR
- The return typerequest
- The HTTP requestprotected boolean matchIfRouteIsNotVersioned(@NonNull HttpRequest<?> request, @Nullable String version)
request
- HTTP Requestversion
- The version resolved evaluating the HTTP Request with beans of type RequestVersionResolver
true
if no version was resolved from the requestprotected boolean matchIfRouteIsVersioned(@NonNull HttpRequest<?> request, @Nullable String resolvedVersion, @NonNull String routeVersion)
request
- HTTP RequestresolvedVersion
- The version resolved evaluating the HTTP Request with beans of type RequestVersionResolver
and the RoutesVersioningConfiguration.getDefaultVersion()
.routeVersion
- The route's version. For example, it could specified by the Version
annotation.true
if the resolved version matches the route version or if the resolved version is null
@NonNull protected Optional<String> resolveVersion(@NonNull HttpRequest<?> request)
request
- HTTP RequestOptional
protected <T,R> Optional<String> getVersion(UriRouteMatch<T,R> routeMatch)