Class PathApiVersionResolver
java.lang.Object
org.springframework.web.reactive.accept.PathApiVersionResolver
- All Implemented Interfaces:
ApiVersionResolver
ApiVersionResolver that extract the version from a path segment.
If the resolver is created with a path index only, it will always return
a version, or raise an InvalidApiVersionException, but never
return null.
The resolver can also be created with an additional
Predicate<RequestPath> that provides more flexibility in deciding
whether a given path is versioned or not, possibly resolving to null.
- Since:
- 7.0
- Author:
- Rossen Stoyanchev, Martin Mois
-
Constructor Summary
ConstructorsConstructorDescriptionPathApiVersionResolver(int pathSegmentIndex) Create a resolver instance.PathApiVersionResolver(int pathSegmentIndex, Predicate<RequestPath> versionPathPredicate) Constructor variant ofPathApiVersionResolver(int)with an additionalPredicate<RequestPath>to help determine whether a given path is versioned (true) or not (false). -
Method Summary
Modifier and TypeMethodDescriptionresolveVersion(ServerWebExchange exchange) Resolve the version for the given exchange.
-
Constructor Details
-
PathApiVersionResolver
public PathApiVersionResolver(int pathSegmentIndex) Create a resolver instance.- Parameters:
pathSegmentIndex- the index of the path segment that contains the API version
-
PathApiVersionResolver
Constructor variant ofPathApiVersionResolver(int)with an additionalPredicate<RequestPath>to help determine whether a given path is versioned (true) or not (false).
-
-
Method Details
-
resolveVersion
Description copied from interface:ApiVersionResolverResolve the version for the given exchange.Implementations of this method are expected to be non-blocking. If you need to resolve the version asynchronously, please implement the
AsyncApiVersionResolversubinterface instead.- Specified by:
resolveVersionin interfaceApiVersionResolver- Parameters:
exchange- the current exchange- Returns:
- the version value, or
nullif not found
-