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) 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
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
-
-
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
-