Package io.micronaut.web.router.version
Class RouteVersionFilter
java.lang.Object
io.micronaut.web.router.version.RouteVersionFilter
- All Implemented Interfaces:
RouteMatchFilter
,VersionRouteMatchFilter
@Singleton
@Requires(beans=RoutesVersioningConfiguration.class)
public class RouteVersionFilter
extends Object
implements VersionRouteMatchFilter
Implementation of
RouteMatchFilter
responsible for filtering route matches on Version
.- Since:
- 1.1.0
- Author:
- Bogdan Oros
-
Constructor Summary
ConstructorDescriptionRouteVersionFilter
(List<RequestVersionResolver> resolvingStrategies, @Nullable DefaultVersionProvider defaultVersionProvider) Deprecated.RouteVersionFilter
(List<RequestVersionResolver> resolvingStrategies, @Nullable DefaultVersionProvider defaultVersionProvider, @Nullable RoutesVersioningConfiguration routesVersioningConfiguration, @Nullable HeaderVersionResolverConfiguration headerVersionResolverConfiguration) Creates aRouteVersionFilter
with a collection ofRequestVersionResolver
. -
Method Summary
Modifier and TypeMethodDescription<T,
R> Predicate<UriRouteMatch<T, R>> filter
(HttpRequest<?> request) Filters route matches by specified version.getVersion
(UriRouteMatch<T, R> routeMatch) protected boolean
matchIfRouteIsNotVersioned
(@NonNull HttpRequest<?> request, @Nullable String version) protected boolean
matchIfRouteIsVersioned
(@NonNull HttpRequest<?> request, @Nullable String resolvedVersion, @NonNull String routeVersion) resolveVersion
(@NonNull HttpRequest<?> request)
-
Constructor Details
-
RouteVersionFilter
@Deprecated public RouteVersionFilter(List<RequestVersionResolver> resolvingStrategies, @Nullable @Nullable DefaultVersionProvider defaultVersionProvider) Creates aRouteVersionFilter
with a collection ofRequestVersionResolver
.- Parameters:
resolvingStrategies
- A list ofRequestVersionResolver
beans to extract version from HTTP requestdefaultVersionProvider
- The Default Version Provider
-
RouteVersionFilter
@Inject public RouteVersionFilter(List<RequestVersionResolver> resolvingStrategies, @Nullable @Nullable DefaultVersionProvider defaultVersionProvider, @Nullable @Nullable RoutesVersioningConfiguration routesVersioningConfiguration, @Nullable @Nullable HeaderVersionResolverConfiguration headerVersionResolverConfiguration) Creates aRouteVersionFilter
with a collection ofRequestVersionResolver
.- Parameters:
resolvingStrategies
- A list ofRequestVersionResolver
beans to extract version from HTTP requestdefaultVersionProvider
- The Default Version ProviderroutesVersioningConfiguration
- Configuration for routes versioningheaderVersionResolverConfiguration
- Configuration for Header Version resolution
-
-
Method Details
-
filter
Filters route matches by specified version.- Specified by:
filter
in interfaceRouteMatchFilter
- Type Parameters:
T
- The target typeR
- The return type- Parameters:
request
- The HTTP request- Returns:
- A filtered list of route matches
-
matchIfRouteIsNotVersioned
protected boolean matchIfRouteIsNotVersioned(@NonNull @NonNull HttpRequest<?> request, @Nullable @Nullable String version) - Parameters:
request
- HTTP Requestversion
- The version resolved evaluating the HTTP Request with beans of typeRequestVersionResolver
- Returns:
true
if no version was resolved from the request
-
matchIfRouteIsVersioned
protected boolean matchIfRouteIsVersioned(@NonNull @NonNull HttpRequest<?> request, @Nullable @Nullable String resolvedVersion, @NonNull @NonNull String routeVersion) - Parameters:
request
- HTTP RequestresolvedVersion
- The version resolved evaluating the HTTP Request with beans of typeRequestVersionResolver
and theRoutesVersioningConfiguration.getDefaultVersion()
.routeVersion
- The route's version. For example, it could specified by theVersion
annotation.- Returns:
true
if the resolved version matches the route version or if the resolved version isnull
-
resolveVersion
@NonNull protected @NonNull Optional<String> resolveVersion(@NonNull @NonNull HttpRequest<?> request) - Parameters:
request
- HTTP Request- Returns:
- the resolved requested version wrapped in an
Optional
-
getVersion
-
RouteVersionFilter(java.util.List<io.micronaut.web.router.version.resolution.RequestVersionResolver>,@io.micronaut.core.annotation.Nullable io.micronaut.web.router.version.DefaultVersionProvider,@io.micronaut.core.annotation.Nullable io.micronaut.web.router.version.RoutesVersioningConfiguration,@io.micronaut.core.annotation.Nullable io.micronaut.web.router.version.resolution.HeaderVersionResolverConfiguration)
instead.